您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 质量控制/管理 > 程序设计教程(用C++语言编程)陈家骏、郑涛编著-答案
1C++1................................................................................................................................................22................................................................................................................43............................................................................................................64......................................................................................................................155..............................................................................................................................206..........................................................................................................................307..................................................................................................................................468..........................................................................................................................692112••CPU3CPUCPUCPU/4536789C++extern,_book,Car,car_1,ca1r,1car,friend,car1_Car,Car_Type,No.1,123C++_book,Car,car_1,ca1r,car1_Car,Car_Type10CC++1.3.2C++C++*.cpp*.hC++C++4*.obj*.exeVisualC++projectprojectBuildBuild...RebuildAllBuildExecute...21C++C++5sizeof()2C++-5.23,1e+50,-25,105,20.20,e5,1e-5,-0.0e5,'\n'-000,'A','5','3.14',falsered,'\r','\f'TodayisMonday.,\-5.23,1e+50,-25,20,.20,1e-5,-0.0e5,'\n',-000,'A','5','\r','\f',TodayisMonday.,\-25,20,-000-5.23,1e+50,.20,1e-5,-0.0e5:'\n','A','5','\r','\f'TodayisMonday.,\312345C++56713/5*12.32'a'+10*5.2312U+3.0F*24L1350double12.3210double5.2’a’double33.0F24Ldouble12Udouble8C++1aacbb242−+−C++sqrt(x)2))()((csbsass−−−3345.2133rcbdcba⋅⋅+++⋅⋅⋅π1(-1*b+sqrt(b*b-4*a*c))/(2*a)2sqrt(s*(s-a)*(s-b)*(s-c))3((a*b)/(c*d))*(3/(1+(b/(2.5+c))))+(4*pi*r*r*r/3)69C++1ij2ch3m4n1005abc1i%j==02((ch='a')&&(ch='z'))||((ch='A')&&(ch='Z'))3m%2==04(n100)&&(n%2!=0)5(a0)&&(b0)&&(c0)&&(a+bc)&&(b+ca)&&(c+ab)((a+b)c)&&(abs(a-b)c)//(a0)&&(b0)&&(c0)10#includeiostreamusingnamespacestd;intmain(){doublea=3.3,b=1.1;inti=a/b;coutiendl;return0;}2double3.03.0-4.44089e-016int211a=b^a;b=a^b;a=b^a;a=a+b;b=a-b;a=a-b;371c=95(f-32)cf#includeiostreamusingnamespacestd;intmain(){doublec,f;coutPleaseinputaF-temperature:endl;cinf;c=(f-32)*5/9;coutTheC-temperatureis:cendl;return0;}22412201620168:16pm8168168:16am#includeiostreamusingnamespacestd;intmain(){inthour,minute;charnoon;coutPleaseinputatimein24-hourformat:endl;couthour:;cinhour;if(hour0||hour23){coutTheinputhouriswrong!endl;exit(-1);}if(hour12){hour=hour-12;noon='p';}elsenoon='a';coutminute:;cinminute;if(minute0||minute59){coutTheinputminuteiswrong!endl;8exit(-1);}coutendlThetimein12-hourformatis:hour:minute;if(noon=='p')coutpmendl;elsecoutamendl;return0;}3az#includeiostreamusingnamespacestd;intmain(){for(charc='a';c='z';c++)coutc;coutendl;for(c='z';c='a';c--)coutc;coutendl;return0;}4#includeiostreamusingnamespacestd;intmain(){unsignedintgzint;intcount=0;while(1){coutPleaseinputainteger(greaterthanzero):endl;cingzint;if(gzint=0)coutYourinputiswrong!Pleaseinputagain...endl;else9break;}while(gzint!=0){gzint=gzint/10;count++;}coutThenumberofdigitsintheintergeris:countendl;return0;}5##includeiostreamusingnamespacestd;intmain(){intcount=0;charch;coutPleaseinputanexpression:endl;for(cinch;ch!='#';cinch){if(ch=='(')count++;elseif(ch==')')count--;}if(count==0)cout!endl;elseif(count0)cout!endl;elsecout!endl;return0;}6=##includeiostream10usingnamespacestd;intmain(){intcount=0;charch1='\0',ch2;coutPleaseinputastring(terminatedwith#):endl;for(cinch2;ch2!='#';cinch2){if(ch2=='='&&ch1=='')count++;ch1=ch2;}coutNumberof=:countendl;return0;}71553094512601410001751510002#includeiostreamusingnamespacestd;intmain(){intcharge;doubleweight;coutPleaseinputtheweightofthepackage:endl;cinweight;if(weight=0)coutTheinputweightiswrong!endl;elseif(weight=15)charge=5;elseif(weight=30)charge=9;elseif(weight=45)charge=12;else11{doubledistance;coutPleaseinputthedistance:endl;cindistance;if(distance=0)coutTheinputeddistanceiswrong!endl;else{distance/=1000;if(weight=60)charge=14+(int)distance;elsecharge=15+(int)distance*2;}}coutchargeendl;return0;}8K+−+−=71513114π10-8#includeiostream#includecmathusingnamespacestd;intmain(){doubleitem=1.0,sum=0.0;inti=1,sign=1;while(fabs(item)=1e-8){sum+=item;sign*=-1;i+=2;item=sign/(double)i;}coutsum*4endl;return0;}912153133353#includeiostreamusingnamespacestd;intmain(){for(intn=100;n=999;n++){inti,j,k;i=n/100;//j=n%100/10;//k=n%10;//if(n==i*i*i+j*j*j+k*k*k)coutnendl;}return0;}#includeiostreamusingnamespacestd;intmain(){for(inti=1;i=9;i++){intn=i*100,m=i*i*i;for(intj=0;j=9;j++){intn1=n+j*10,m1=m+j*j*j;for(intk=0;k=9;k++){if(n1+k==m1+k*k*k)coutn1+kendl;}}}return0;}10ab#includeiostreamusingnamespacestd;intmain(){inta,b;13coutPleaseinputa,b:endl;cinab;intc=(ab
本文标题:程序设计教程(用C++语言编程)陈家骏、郑涛编著-答案
链接地址:https://www.777doc.com/doc-5028192 .html