HDU 1170

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
    int t;
    char c;
    int a, b;
    while(cin>>t)
    {
        while(t--)
        {
            cin>>c>>a>>b;
            if(c == '+')
                cout<<a + b<<endl;
            else if(c == '-')
                cout<<a - b<<endl;
            else if(c == '*')
                cout<<a * b<<endl;
            else {
                if(a % b == 0)
                    cout<<a/b<<endl;
                else 
                {
                    double x = a, y = b;
                    printf("%.2lf\n", x / y);
                }
            }
        }
    }
    return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章