hdoj-1070-Balloon Comes!

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;
}

你可能感兴趣的:(hdoj-1070-Balloon Comes!)