hdoj-1070-Balloon Comes!

来源:互联网 发布:地下水埋深数据 编辑:程序博客网 时间:2024/05/18 13:31

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

#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;int main(){    int t;    scanf("%d",&t);    while(t--)    {        getchar();        char c;        int a,b;        scanf("%c",&c);        scanf("%d%d",&a,&b);        if(c=='+')        {            printf("%d\n",a+b);        }        else if(c=='-')        {            printf("%d\n",a-b);        }        else if(c=='/')        {            if(a%b==0) printf("%d\n",a/b);            else            {                double n=double(a)/b;                printf("%.2lf\n",n);            }        }        else if(c=='*')printf("%d\n",a*b);    }    return 0;}
0 0