AC代码:
#include<cmath>
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main()
{
double x, y,ans;
char ch;
cin >> x >> y;
cin >> ch;
switch (ch)
{
case '+': ans = x + y; cout << fixed << setprecision(1) << ans << endl; break;
case'-': ans = x - y; cout << fixed << setprecision(1) << ans << endl; break;
case'*':ans = x*y; cout << fixed << setprecision(1) << ans << endl; break;
case'/':
{
if (y == 0)cout << "Wrong!";
else { ans = x / y; cout << fixed << setprecision(1) << ans << endl; break;
}
}
}
return 0;
}