zoukankan      html  css  js  c++  java
  • 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习4

    #include <iostream>
    using namespace std;
    const int strsize=30;
    const int BOPSIZE=5;
    void showmenu()
    {
    	cout<<"Benevolent Order of Programmers Report
    "
    	     "a. display by name     b. display by title
    "
    		 "c. display by bopname  d. display by preference
    "
    		 "q. quit
    ";
    }
    struct bop
    {
    	char fullname[strsize];
    	char title[strsize];
    	char bopname[strsize];
    	int preference;
    };
    int main()
    {
    	showmenu();
    	char ch;
    	int i;
    	bop newbop[BOPSIZE]=
    	{
    		{"Wimp Macho","Teahcer","WWW",0},
    		{"Raki Rhodes","Junior Programmer","RRR",1},
    		{"Celia Laiter","Star","MIPS",2},
    		{"Hoppy Hipman","Analyst Trainee","HHH",1},
    		{"Pat Hand","Doctor","LOOPY",2}
    	};
    	cout<<"Enter your choice: ";
    	while(cin>>ch && ch!='q')
    	{
    		switch(ch)
    		{
    		case 'a':
    			for(i=0;i<BOPSIZE;i++)
    				cout<<newbop[i].fullname<<endl;
    			break;
    		case 'b':
    			for(i=0;i<BOPSIZE;i++)
    				cout<<newbop[i].title<<endl;
    			break;
    		case 'c':
    			for(i=0;i<BOPSIZE;i++)
    				cout<<newbop[i].bopname<<endl;
    			break;
    		case 'd':
    			for(i=0;i<BOPSIZE;i++)
    			{
    				if(0==newbop[i].preference)
    					cout<<newbop[i].fullname<<endl;
    				else if(1==newbop[i].preference)
    					cout<<newbop[i].title<<endl;
    				else if(2==newbop[i].preference)
    					cout<<newbop[i].bopname<<endl;
    			}
    		  	  break;
    		  //case 'q':cout<<"Bye!
    ";
    		}
    		cout<<"Next choice: ";
    	}
    	cout<<"Bye!
    ";
    	system("pause");
    	return 0;
    }
    		
    
  • 相关阅读:
    网络流,再出发!
    2SAT
    并查集
    最大密度子图
    网络流提高专题(洛谷题单)
    JQuery 操作 ListBox间移动和ListBox内移动
    关于多表Update和Delete的应用
    XML格式与DataTable、DataSet、DataView格式的转换
    FCKeditor配置和精简
    点击fileupload后button事件不起作用
  • 原文地址:https://www.cnblogs.com/lynnycy/p/3453207.html
Copyright © 2011-2022 走看看