日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

ccpp5 编程练习6.4

發布時間:2025/5/22 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ccpp5 编程练习6.4 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

此網站上有參考XD:?

http://www.ignatkov.net/cppprimerplus/

5月3日查看,此網站已被黑。

// ex6.4 // 希望回頭想到好辦法 #include <iostream> using namespace std; const int strsize = 20; // 20 或許有點小 const int NUM = 5; void showmenu(); // Benevolent Order of Programmers name structure struct bop {char fullname[strsize]; // real namechar title[strsize]; // job titlechar bopname[strsize]; // secret BOP nameint preference; // 0 = fullname, 1 = title, 2 = bopname };int main () {// 除了書上貼出來的信息,其他瞎編bop bops[NUM] = {{"Wimp Macho", "Farmer", "Wim", 0},{"Raki Rhodes", "Junior Programmer", "Rak", 1},{"Celia Laiter", "Driver", "MIPS", 2},{"Hoppy Hipman", "Analyst Trainee", "Hop", 1},{"Pat Hand", "Teacher", "LOOPY", 2}};showmenu();char ch; // choicecout << "Enter your choice: ";int i; // 不重復聲明了// 這個寫的復雜了,希望能想出好辦法while (cin >> ch && ch != 'q'){switch (ch){case 'a': for (i = 0; i < NUM; i++)cout << bops[i].fullname << endl;break;case 'b': for (i = 0; i < NUM; i++)cout << bops[i].title << endl;break;case 'c': for (i = 0; i < NUM; i++)cout << bops[i].bopname << endl;break;case 'd': for (i = 0; i < NUM; i++){switch (bops[i].preference){case 0: cout << bops[i].fullname << endl; break;case 1: cout << bops[i].title << endl; break;default: cout << bops[i].bopname << endl;}}break;default: break;}// 吞掉后面多掛的字符while ((ch = cin.get()) != '\n')continue;cout << "Next choice: ";}cout << "Bye!\n";return 0; }void showmenu() {cout << "Benevolent Order of Programmers Report\n""a. display by name b. display by title\n""c. display by bopname d. display by preference\n""q. quit\n";return; }

轉載于:https://my.oschina.net/u/727594/blog/119006

總結

以上是生活随笔為你收集整理的ccpp5 编程练习6.4的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。