c++试题库编程题.docx
《c++试题库编程题.docx》由会员分享,可在线阅读,更多相关《c++试题库编程题.docx(22页珍藏版)》请在第壹文秘上搜索。
1、/2-5#include#include#includeusingnamespacestd;classTriangleinta,b,c;public:doubleArea()(doubles=(a+b+c)2;returnsqrt(s*(s-a)*(s-b)*(s-c););intPerimeterOreturna+b+c;)voidInput()cinabc;);voidmain()Triangletl;tl.Input();couttl.Area(),tl.Perimeter();)/2-3#includeinlineintmax(intajntb)(if(ab)returna;elser
2、eturnb;Jinlineintmax(inta,intb,intc)(returnmax(a,max(b,c);)voidmain()(intx=2l,y=15,z=22,d;d=max(x,max(y,z);coutd;)/2-4#includeintoverload(intn);charoverload(charn);voidmain()(intn;chars;CoUtn;coutn=,overload(n)endl;COUt”输入a,s;couta=;coutoverload(s)endl;)intoverload(intn)(returnn;)charoverload(charn)
3、(coutbendl;returnO;)/2-2#includeiostreamusingnamespacestd;inlinechartrans(charch);intmain()(charch;while(ch=getchar()!=n,)couttrans(ch);cout=aAfcch=,z,)returnch-32;elsereturnch+32;)/3-l#inc1udeusingstd:cout;usingstd:endl;intMin(inta,intb)(return(ab?a:b);)intMin(inta,intb,intc)return(Min(a,b)c?Min(a,
4、b):c);intMin(inta,intb,intc,intd)(return(Min(a,b,c)d?Min(a,b,c):d);)voidmain(void)(coutMIN(l,2)=,Min(l,2)endl;coutMIN(3,4,5)=,Min(3A5)endl;coutMIN(4,5,6,7)=,Min(4,5,6,7)endl;)/3-2#includeusingnamespacestd;voidArea(floatr)(coutthecirclesareais:3.14*r*rendl;)voidArea(floata,floatb)(couttherectangles(s
5、quare,s)areais:,a*bendl;)voidArea(floata,floatb,floath)(coutthetrapzoid,sareais:,(a+b)*h2endl;)voidmain()(Area(5);Area(3,3);Area(3,5,4);)/3-3#includeusingnamespacestd;voidSort(inta,intn)(boolflag;fbr(inti=0jn-l;i+)(flag=false;fbr(intj=l;jaj)inttemp=aj-l;aj-l=aj;ajj=temp;flag=true;)if(!flag)break;1fo
6、r(intm=O;mn;m+)coutam;coutendl;)voidSort(floatblJ,intn)(boolflag;fr(inti=0;in-l;i+)(flag=false;fbr(intj=l;jbUD(floattemp=bj-l;bj-l=bj;bj=temp;flag=true;)if(!flag)break;1for(intm=0;mn;m+)coutbm,;coutendl;)voidmain()(intal0=3,5,2,9,0,8,6,4,7;floatbl10=0.1,0.2,03A4,0.5,0.6,0.7,0.8,0.9,1.0);Sort(a,10);S
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- c+ 试题库 编程