Acm hdu 1170 balloon comes! (Complete water questions, plus, subtraction, multiplication, division)

Source: Internet
Author: User
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 ;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.