HDU 1170 Balloon Comes!

#include <cstdio>

#include <iostream>

using namespace std;

int main()

{

    int n;

    scanf("%d",&n);

    for(int i=1; i<=n; i++)

   {

        char c,demo;

        int a,b;

        scanf("%c%c%c%d%c%d",&demo,&c,&demo,&a,&demo,&b);

        if (c=='+') printf("%d\n",a+b);

        if (c=='-') printf("%d\n",a-b);

        if (c=='*') printf("%d\n",a*b);

        if (c=='/') 

        {

             (a%b==0)?printf("%d\n",a/b):printf("%0.2f\n",(float)a/(float)b);   

        }

    } 

    //system("pause");

    return 0;

}

 

你可能感兴趣的:(com)