#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int counter;
char op;
int a, b;
cin >> counter;
for (int i = 0; i < counter; i++)
{
cin >> op >> a >> b;
if (op == '+')
cout << a+b << endl;
else if (op == '-')
cout << a-b << endl;
else if (op == '*')
cout << a*b << endl;
else
{
if (a % b == 0)
cout << int(a/b) << endl;
else
{
cout.setf(ios_base::showpoint);
cout.precision(2);
cout << float(a)/b << endl;
}
}
}
return 0;
}
杭电 ACM steps 1.2.6
想不通为什么一直是wrong answer。网上找到的能accepted的使用C风格写的。
我花了很多时间在这道“简单的题”上,哈哈。。。。还是没能找出原因