Balloon comes!
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 10546 accepted submission (s): 3623
Problem descriptionthe contest starts now! How excited it is to see balloons floating around. you, one of the best programmers in HDU, can get a very beautiful balloon if only you have solved the very... easy problem.
Give you an operator (+,-, *,/-- denoting addition, subtraction, multiplication, division respectively) and two positive integers, your task is to output the result.
Is it very easy?
Come on, guy! Plmm will send you a beautiful balloon right now!
Good luck!
Inputinput contains multiple test cases. the first line of the input is a single integer T (0 <t <1000) which is the number of test cases. t test cases follow. each test case contains a char C (+,-, *,/) and two integers A and B (0 <a, B <10000 ). of course, we all know that A and B are operands and C is an operator.
Outputfor each case, print the operation result. The result shocould be rounded to 2 decimal places if and only if it is not an integer.
Sample input4 + 1 2-1 2*1 2/1 2
Sample output3-1 2 0.50
Authorlcy water question, note
The result shoshould be rounded to 2 decimal places if and only if it is not an integer. It is used for Division. If the division is to output an integer, because this WR has
# Include < Stdio. h >
# Include < Iostream >
Using Namespace STD;
Int Main ()
{
Int T, A, B;
Char Ch;
Scanf ( " % D " , & T );
While (T -- )
{
CIN > Ch > A > B;
If (CH = ' + ' ) Printf ( " % D \ n " , + B );
Else If (CH = ' - ' )
Printf ( " % D \ n " , - B );
Else If (CH = ' * ' )
Printf ( " % D \ n " , * B );
Else
{
If ( % B = 0 ) Printf ( " % D \ n " , / B ); // Note that you can see the meaning of the question
Else
Printf ( " %. 2f \ n " ,( Float ) / B );
}
}
Return 0 ;
}