#include <bits/stdc++.h>
using namespace std;
int main(){
char c,symbol;
int now[2]={-1,-1},ans,j=1;
while(cin>>c){
if(c!="+" && c!="-"){
if(now[0]==-1){
now[0]=(int)c*j;
j*=10;
}
else {
now[1]=(int)c*j;
j*=10;
}
}
else {
symbol=c;
}
if(now[0]!=-1 && now[1]!=-1){
if(symbol=="+")ans=ans+now[0]+now[1];
else ans=ans+now[0]-now[1];
}
}
cout<<ans<<endl;
return 0;
}
为什么编译错误
为“ISO c++禁止指针和整数之间的比较”
在7和21