#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;
}
}
6.4 c++prozuoye
最新推荐文章于 2024-08-12 16:55:46 发布