参考流程图并编写程序

参考流程编写程序,提示用户输入相关信息,输出相应结果。status 为0表示退休了,status为1表示正在工作。
输入形式:68
0
输出形式:Please input age:
Please input status:
Retired senior

img

根据流程图用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;
}

 

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632