改进计算器小程序
bool RunCalculator();
int main()
{
cout<<"计算器!"<<endl;
while(true){
bool is Continue= RunCalculator();
if(isContinue==false)
break;
}
return 0;
}
bool RunCalculator(){
int operator1;
cout<<"Enter the first number:";
cin>>operator1;
int operator2;
cout<<"Enter the second number:";
cin>>operator2;
int res=operator1+operator2;
cout<<"Result is:"<<res<<endl;
cout<<"Continue calculating?(y/n)<<endl;
char c;
cin>>c;
if(c=='y'){
return true;
}
else{
return false;
}
}