美文网首页
1170 Balloon Comes!

1170 Balloon Comes!

作者: 李清依 | 来源:发表于2017-11-27 16:45 被阅读0次

Balloon Comes!

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 32087 Accepted Submission(s): 12060**</font>

Problem Description

The 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 very 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!

Input

Input 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.

Output

For each case, print the operation result. The result should be rounded to 2 decimal places If and only if it is not an integer.

Sample Input

4

  • 1 2
  • 1 2
  • 1 2
    / 1 2

</pre>

Sample Output

3
-1
2
0.50

</pre>

Author

lcy

Recommend

We have carefully selected several similar problems for you: 1061 1021 1008 1108 1005
AC代码:

#include<stdio.h> 
#include "string.h" 
int main()  
{
    int i,x,y,m;
    double sum;
    char c[10];
    scanf("%d",&m);
    for ( i=0;i<m;i++)
    {
        scanf("%s",&c);
        scanf("%d%d",&x,&y);
        if (c[0]=='+')
        {
            sum=x+y;
            printf("%d\n",x+y);
        }
        else if (c[0]=='-')
        {
            sum=x-y;
            printf("%d\n",x-y);
        }
        else if (c[0]=='*')
        {
            sum=x*y;
            printf("%d\n",x*y);
        }
        else if (c[0]=='/')//注意这里的坑,如果不能整除的情况
        {
            if (x%y)//不能为0的时候
            {
                printf("%.2f\n",x*1.0/y);//注意需要乘以1.0
            }
            else
                printf("%d\n",x/y);
        }
    }
    
}  

相关文章

  • 1170 Balloon Comes!

    Balloon Comes! Time Limit: 2000/1000 MS (Java/Others) ...

  • Stepping on balloons every day -

    Stepping on the balloon every day is a colorful balloon g...

  • balloon

    做什么事都感到吃力的时候,意识到了时间的流逝。 人生如逆水行舟,不进则退。 某一时刻突然感到疲惫,需要喘喘气才可以...

  • Balloon Hat

    I have a ballon hat. It is an umbrella when I put it on m...

  • A dream balloon🎈🎈🎈

    新鲜出炉的处女秀绘本来了!

  • Confession Balloon

    rewind v.重绕(磁带等);倒带;倒片 n. 重绕;倒带器 confession n.自认;自白;招供;忏...

  • Balão de Carnaval: Tap & Shoot

    Carnival came to the playground, there is a balloon shoot...

  • 1170

    有人说:“相比于贫穷与平庸,我们更害怕被嘲笑。粗茶淡饭并不会导致直接性的痛苦,但冷嘲热讽会。其实呢,如果周围有爱,...

  • Privacy Policy

    The "Poke the balloon-Archery" app respects and protects ...

  • Comes

    我在弃了简书一年后,我回来啦。

网友评论

      本文标题:1170 Balloon Comes!

      本文链接:https://www.haomeiwen.com/subject/qzedbxtx.html