65,210
社区成员
发帖
与我相关
我的任务
分享#include <iostream>
struct bop{
char fullname[100]; //real name
char title[100]; //job title
char bopname[100]; //secret bop name
int preference; //0=fullname,1=job title,2=bopname
};
main()
{
using namespace std;
char ch;
cout<<"Bene volent Order of Programmers Report"<<endl;
cout<<"a.display by name b.diaplay by title" <<endl;
cout <<"c.display by bopname d.diaplay by preference" <<endl;
cout <<"q.quit" <<endl;
cout <<"Enter your choice:";
cin.get(ch);
while((ch)!='Q'&&(ch)!='q')
{
switch(ch)
{
case 'a': cout <<"Wimp Macho" <<endl <<"Raki Rhodes" <<endl <<"Celia Laiter" <<endl;
cout <<"Hoppy Hipman" <<endl <<"Pat Had" <<endl;
break;
case 'b': cout <<"student" <<endl <<"Junior Programmer" <<endl <<"docter" <<endl;
cout <<"Analyst" <<endl <<"boss" <<endl;
break;
case 'c': cout <<"Love" <<endl <<"Bud" <<endl <<"MIPS" <<endl;
cout <<"Flower" <<endl <<"LOOPY" <<endl;
break;
case 'd': cout <<"Wimp Macho" <<endl <<"Junior Programmer" <<endl <<"MIPS" <<endl;
cout <<"Analyst" <<endl <<"LOOPY" <<endl;
break;
default: break;
}
fflush(stdin); ///加上这一句就没问题了。
cout <<"Next choice:";
cin.get(ch);
}
if(ch=='Q'||ch=='q') cout <<"Bye!" <<endl;
return 0;
}