Run ID:92569

提交时间: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; }