参考流程编写程序,提示用户输入相关信息,输出相应结果。status 为0表示退休了,status为1表示正在工作。
输入形式:68
0
输出形式:Please input age:
Please input status:
Retired senior
根据流程图用if else来判断就可以了
#include<iostream>
using namespace std;
int main(){
int status,age;
cout<<"Please input age:";
cin>>age;
cout<<"Please input status:";
cin>>status;
if(age>59){
if(status==1){
cout<<"Working senior"<<endl;
}else{
cout<<"Retired senior"<<endl;
}
}else{
if(age>20){
cout<<"Adult"<<endl;
}else if(age>12){
cout<<"Teen"<<endl;
}else{
cout<<"Child"<<endl;
}
}
return 0;
}
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!