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;
    }
    		
    
  • 相关阅读:
    Linux命令行工具之pidstat命令
    Linux命令行工具之vmstat命令
    进程的状态与转换
    curl常用命令
    Linux常用命令
    TCP TIME_WAIT和CLOSE_WAIT
    OSI参考模型与TCP/IP参考模型与TCP/IP协议栈
    限流算法
    正向代理和反向代理
    oracle全量、增量备份
  • 原文地址:https://www.cnblogs.com/lynnycy/p/3453207.html
Copyright © 2011-2022 走看看