Title Description
Description
Enter the original ticket price (3 to 4 positive integer, Unit: Yuan), and then enter the ticket discount rate (up to one digit after the decimal point). program calculates the actual price of the ticket after discount (unit: Yuan. The result of the calculation is to round the single digit to the 10-digit "element". The input is only a single row of two numbers (two spaces separated by a space), the first is an integer, the ticket price, the second integer or real number (as real, up to 1 digits after the decimal point) represents the discount rate.
Input Sample 1:
888 7
Output Example 1:
620
Input Sample 2:
1255 7
Output Example 2:
880
Enter a description
Input Description
The input is only a single row of two numbers (two spaces separated by a space), the first is an integer, the ticket price, the second integer or real number (as real, up to 1 digits after the decimal point) represents the discount rate.
Output description
Output Description
The output is only a single positive integer representing the discounted ticket price.
Sample input
Sample Input
888 7
Sample output
Sample Output
620
Data range and Tips
Data Size & Hint
The original ticket price is greater than 100 less than 9999, the discount rate is greater than 1 less than 9.9.
Idea: This problem is a bit complicated, you can save the ticket price and discount rate with two float floats, then calculate the product divided by 100 (why divide by 100, because to keep to 10 bits, if divided by 10 is only reserved to the bit, and then the result is returned to 10), you can use: = (int) (x+0.5 ) > (int) x? (int) x+1: (int) x This code to implement rounding, int type Y, floating-point type X, returns the result after rounding
The code is as follows:
1#include <stdio.h>2 intMain ()3 {4 floatb;5 floatC;6 intans;7scanf"%f%f",&a,&b);8c=a*b/ -;9Ans= (int) (c+0.5) > (int(c^ (int) c+1:(int) C;Tenprintf"%d\n", ans*Ten); One return 0; A}
code[vs]-Ticket Discount-floating point processing-ladder Bronze