Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
92569 | 牛延希 | 22计算算术表达式 | C++ | Accepted | 1 MS | 280 KB | 683 | 2024-10-05 17:15:36 |
#include<iostream> using namespace std; int main(){ char s; int n,x,y,flag; string a; cin>>n; for(int i=0;i<n;i++){ cin>>a; x=y=0; flag=0; for(int j=0;j<a.size();j++){ if(a[j]>='0' && a[j]<='9'){ if(flag){ y=y*10+a[j]-'0'; }else{ x=x*10+a[j]-'0'; } }else{ flag=1; s=a[j]; } }if(s=='+'){ cout<<x+y<<endl; }else if(s=='-'){ cout<<x-y<<endl; }else if(s=='*'){ cout<<x*y<<endl; }else if(s=='/'){ cout<<x/y<<endl; }else{ cout<<x%y<<endl; } } return 0; }