您的位置:首页 > 其它

hdoj-1070-Balloon Comes!

2016-04-14 20:43 260 查看
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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: