欢迎来到天天文库
浏览记录
ID:61502188
大小:34.50 KB
页数:10页
时间:2021-02-07
《C++Primer Plus第六章编程练习.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、第六章编程练习1、#include#includeintmain(){usingnamespacestd;charch;cin.get(ch);while(ch!='@'){if(isdigit(ch))cin.get(ch);else{if(islower(ch))ch=toupper(ch);elsech=tolower(ch);cout<2、m>intmain(){usingnamespacestd;doublesum=0;doubleaverage=0;doublenum[10];inti=0,total=0;doubletmp;while(cin>>tmp&&i<10){num[i]=tmp;sum+=num[i];++i;}if(i!=0)average=sum/i;for(intj=0;javerage)++total;cout<<"这些数字的平均值为"<3、<"并且共有"<intmain(){usingnamespacestd;cout<<"Pleaseenteroneofthefollowingchoices:"<<"c)carnivorep)pianist"<<"t)treeg)gamef";cout<<"Pleaseenterac,p,t,org:";charch;cin>>ch;while(ch!4、='c'&&ch!='p'&&ch!='t'&&ch!='g'){cout<<"Pleaseenterac,p,t,org:";cin>>ch;}switch(ch){case'c':cout<<"Amapleisatree.";break;case'p':cout<<"Amapleisapianist.";break;case't':cout<<"Amapleisatree.";break;case'g':cout<<"Amapleisagame.";}system("pause"5、);return0;}4、#includeconstintstrsize=20;structbop{charfullname[strsize];chartitle[strsize];charbopname[strsize];intpreference;};intmain(){std::cout<<"BenevolentOrderofProgrammersReport""a.displaybynameb.displaybytitle""c.displaybybopnamed6、.diplaybypreference""q.quit";charch;bopmember[5]={{"WimpMacho","EnglishTeacher","DEMON",0},{"RakiRhodes","JuniorProgrammer","BOOM",1},{"CeliaLaiter","SuperStar","MIPS",2},{"HoppyHipman","AnalystTrainee","WATEE",1},{"PatHand","Police","LOOPY",2}};std:7、:cout<<"Enteryourchoice:";while(std::cin>>ch&&ch!='q'){switch(ch){case'a':for(inti=0;i<5;i++)std::cout<8、ber[i].bopname<
2、m>intmain(){usingnamespacestd;doublesum=0;doubleaverage=0;doublenum[10];inti=0,total=0;doubletmp;while(cin>>tmp&&i<10){num[i]=tmp;sum+=num[i];++i;}if(i!=0)average=sum/i;for(intj=0;javerage)++total;cout<<"这些数字的平均值为"<3、<"并且共有"<intmain(){usingnamespacestd;cout<<"Pleaseenteroneofthefollowingchoices:"<<"c)carnivorep)pianist"<<"t)treeg)gamef";cout<<"Pleaseenterac,p,t,org:";charch;cin>>ch;while(ch!4、='c'&&ch!='p'&&ch!='t'&&ch!='g'){cout<<"Pleaseenterac,p,t,org:";cin>>ch;}switch(ch){case'c':cout<<"Amapleisatree.";break;case'p':cout<<"Amapleisapianist.";break;case't':cout<<"Amapleisatree.";break;case'g':cout<<"Amapleisagame.";}system("pause"5、);return0;}4、#includeconstintstrsize=20;structbop{charfullname[strsize];chartitle[strsize];charbopname[strsize];intpreference;};intmain(){std::cout<<"BenevolentOrderofProgrammersReport""a.displaybynameb.displaybytitle""c.displaybybopnamed6、.diplaybypreference""q.quit";charch;bopmember[5]={{"WimpMacho","EnglishTeacher","DEMON",0},{"RakiRhodes","JuniorProgrammer","BOOM",1},{"CeliaLaiter","SuperStar","MIPS",2},{"HoppyHipman","AnalystTrainee","WATEE",1},{"PatHand","Police","LOOPY",2}};std:7、:cout<<"Enteryourchoice:";while(std::cin>>ch&&ch!='q'){switch(ch){case'a':for(inti=0;i<5;i++)std::cout<8、ber[i].bopname<
3、<"并且共有"<intmain(){usingnamespacestd;cout<<"Pleaseenteroneofthefollowingchoices:"<<"c)carnivorep)pianist"<<"t)treeg)gamef";cout<<"Pleaseenterac,p,t,org:";charch;cin>>ch;while(ch!
4、='c'&&ch!='p'&&ch!='t'&&ch!='g'){cout<<"Pleaseenterac,p,t,org:";cin>>ch;}switch(ch){case'c':cout<<"Amapleisatree.";break;case'p':cout<<"Amapleisapianist.";break;case't':cout<<"Amapleisatree.";break;case'g':cout<<"Amapleisagame.";}system("pause"
5、);return0;}4、#includeconstintstrsize=20;structbop{charfullname[strsize];chartitle[strsize];charbopname[strsize];intpreference;};intmain(){std::cout<<"BenevolentOrderofProgrammersReport""a.displaybynameb.displaybytitle""c.displaybybopnamed
6、.diplaybypreference""q.quit";charch;bopmember[5]={{"WimpMacho","EnglishTeacher","DEMON",0},{"RakiRhodes","JuniorProgrammer","BOOM",1},{"CeliaLaiter","SuperStar","MIPS",2},{"HoppyHipman","AnalystTrainee","WATEE",1},{"PatHand","Police","LOOPY",2}};std:
7、:cout<<"Enteryourchoice:";while(std::cin>>ch&&ch!='q'){switch(ch){case'a':for(inti=0;i<5;i++)std::cout<8、ber[i].bopname<
8、ber[i].bopname<
此文档下载收益归作者所有