6.4 c++prozuoye

#include<iostream>
	
const int strsize = 100;
using namespace std;
void show_real_name(struct bop message[],int n);
void show_job_title(struct bop message[],int n);
void show_bop_name(struct bop message[],int n);
void show_preference(struct bop message[],int n);
void enter_message(struct bop message[],int n);
struct bop
{
	char fullname[strsize]; //real name
	char title[strsize];	//job titel
	char bopname[strsize];  //secret BOP name
	int preference;  	//0=fullname,1=title,2=bopname
};
int main()
{
	int n;
	struct bop message[5] = 
	{
        	{"Wimp Macho", "Da shi xiong", "da sheng", 1},
        	{"Raki Rhodes", "Er shi xiong", "tian peng", 1},
        	{"Celia laiter", "Boss", "tang seng", 1},
        	{"Hoppy Hipman", "Pao tui", "wu jing", 2},
        	{"Pat Hand", "Xiao lao di", "bai long", 0}
    	};
	
	cout << "Benevolent Order of Programmers Report"<<endl;
	cout << "a)display by name     "<<"        "<<"b)display by title     "<<endl
		<<"c)display by bopname   "<<"        "<<"d)display by preference"<<endl
		<<"q)quit    "<<endl
		<<"Please enter q to quit"<<endl;
	char  choice;
	while(cin >> choice && choice !='q')
	{
		switch(choice)
		{
			case 'a' :show_real_name(message,5);
				  cout << endl;
				  break;
			case 'b' :show_job_title(message,5);
				  cout <<endl;
				  break;
			case 'c' :show_bop_name(message,5);
				  cout << endl;
				  break;
			case 'd' :show_preference(message,5);
				  cout <<endl;
				  break;
			
			default :cout<< "Please enter a choice"<<endl;
		}
		
	}
	return 0;
	
}

void show_real_name(struct bop message[],int n)
{
	for(int i =0;i<n;i++)
		cout << message[i].fullname<<endl;
}
void show_job_title(struct bop message[],int n)
{
        for(int i =0;i<n;i++)
                cout << message[i].title<<endl;
}

void show_bop_name(struct bop message[],int n)
{
        for(int i =0;i<n;i++)
                cout << message[i].bopname<<endl;
}

void show_preference(struct bop message[],int n)
{
        for(int i =0;i<n;i++)
	{
		if(message[i].preference==0)
			cout<<message[i].fullname<<endl;
		if(message[i].preference==1)
                        cout<<message[i].title<<endl;
		if(message[i].preference==2)
                        cout<<message[i].bopname<<endl;
	
	}
		
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值