加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

6.4 c++prozuoye

发布时间:2020-12-15 04:51:41 所属栏目:百科 来源:网络整理
导读:#include 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 messag

#include

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",

{"Celia laiter","Boss","tang seng",

{"Hoppy Hipman","Pao tui","wu jing",2},

{"Pat Hand","Xiao lao di","bai long",0}

};

cout << "Benevolent Order of Programmers Report"<

cout << "a)display by name "<<" "<<"b)display by title "<

<<"c)display by bopname "<<" "<<"d)display by preference"<

<<"q)quit "<

<<"Please enter q to quit"<

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 <

break;

case 'c' :show_bop_name(message,5);

cout << endl;

break;

case 'd' :show_preference(message,5);

cout <

break;

default :cout<< "Please enter a choice"<

}

}

return 0;

}

void show_real_name(struct bop message[],int n)

{

for(int i =0;i

cout << message[i].fullname<

}

void show_job_title(struct bop message[],int n)

{

for(int i =0;i

cout << message[i].title<

}

void show_bop_name(struct bop message[],int n)

{

for(int i =0;i

cout << message[i].bopname<

}

void show_preference(struct bop message[],int n)

{

for(int i =0;i

{

if(message[i].preference==0)

cout<

if(message[i].preference==1)

cout<

if(message[i].preference==2)

cout<

}

}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读