Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
1558 | 孙浚轩 | 09计算算数表达式 | C++ | Compile Error | 0 MS | 0 KB | 1609 | 2023-10-14 23:14:45 |
#include<iostream> #include<iomanip> #include<cstdio> #include<cmath> using namespace std; int main() { /*string sc; cout<<"是否开启科学计算器(yes/no)"; cin>>sc; if(sc=="yes") { cout<<"敬请期待"; } else if(sc=="no") {*/ double a,b; int r; char op; //cout<<"请输入:a op(+-*/%) b"; cin>>a>>op>>b; //cout<<"保留多少位小数?(最多16位)"<<endl; cin>>r; if (r>16) { cout<<"超出可保留小数位上限"; } else if (r<0) { cout<<"格式错误"; } else { if (op=='+') { cout<<fixed<<setprecision(r)<<a+b; } else if (op=='-') { cout<<fixed<<setprecision(r)<<a-b; } else if (op=='*') { cout<<fixed<<setprecision(r)<<a*b; } else if (op=='/') { if (b!=0) { cout<<fixed<<setprecision(r)<<a/b; } else { cout<<"错误"; } } else if (op=='%') { cout<<fixed<<setprecision(r)<<a-b*(long long)(a/b); } else { cout<<"格式错误"; } } } else { cout<<"格式错误"; } return 0; }
Main.cc:67:5: error: expected unqualified-id before 'else' else ^ Main.cc:71:5: error: expected unqualified-id before 'return' return 0; ^ Main.cc:72:1: error: expected declaration before '}' token } ^