Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
92565 牛延希 22计算算术表达式 C++ Compile Error 0 MS 0 KB 670 2024-10-05 17:12:11

Tests(0/0):


Code:

#include<iostream> using namespace std; int main(){ char s; int n,x,y; 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]; }else{ x=x*10+a[j]; } }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; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:12:5: error: 'flag' was not declared in this scope
     flag=0;
     ^
Main.cc:13:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=0;j