1-7-1//输出一个数的10倍#includeiostreamusingnamespacestd;intmain(){coutPleaseinputaninterger:\n;inta;cina;coutresult=a*10endl;return0;}1-7-2//输出两个数中的较小的#includeiostreamusingnamespacestd;intmain(){doublex,y,min;coutpleaseinputtwonumbersendl;cinxy;min=(xy?y:x);coutthesmalleris''minendl;return0;}1-7-3//输入半径计算周长和面积#includeiostreamusingnamespacestd;intmain(){cout请输入半径\n;doublerad;cinrad;doublec,s;c=2*3.14*rad;s=3.14*rad*rad;cout周长是cendl;cout面积是sendl;return0;}1-7-4//将10000秒化成小时分钟秒#includeiostreamusingnamespacestd;intmain(){inthour,min,second;hour=10000/3600;min=(10000%3600)/60;second=10000-hour*3600-60*min;couthourhoursminminutessecondsecondsendl;return0;}1-7-5//将一个三位数倒叙输出#includeiostreamusingnamespacestd;intmain(){intnum,num_bai,num_shi,num_ge;cout请输入一个三位数;cinnum;num_bai=num/100;num_shi=(num-num_bai*100)/10;num_ge=num-num_bai*100-num_shi*10;coutnum_geendl;coutnum_shiendl;coutnum_baiendl;return0;}2-3//简单的输入输出#includeiostreamusingnamespacestd;intmain(){doubley,n;coutpleaseinputanumber\n;cinn;if(n0)y=n+1;if(n0)y=n*n;if(n==0)y=0;couttheresultis:''y;return0;}2-4//输出学生学号和对应的成绩等级#includeiostreamusingnamespacestd;intmain(){doublefenshu;intxuehao;chardengji;inti;for(i=1;i=10;i++){onerror:coutpleaseinputstudentscore\n;cinfenshu;if(fenshu=90&&fenshu=100)dengji='A';if(fenshu=80&&fenshu90)dengji='B';if(fenshu=600&&fenshu80)dengji='C';if(fenshu=0&&fenshu60)dengji='D';if(fenshu0){couterror;gotoonerror;}if(fenshu100){couterror;gotoonerror;}couttheidisiendl;coutthescoreisdengjiendl;}return0;}2-5//判断输入字符类别#includeiostreamusingnamespacestd;intmain(){charzifu;intascii;coutpleaseinputacharacteristic\n;cinzifu;ascii=zifu;if(ascii=48&&ascii=57){cout数字\n;gotoend;}if(ascii=97&&ascii=122){cout小写字母\n;gotoend;}if(ascii=65&&ascii=90){cout大写字母\n;gotoend;}cout其他字符;coutendl;end:return0;}2-6//求圆周率的近似值#includeiostream#includeiomanipusingnamespacestd;intmain(){intxishu=-1;doubledanshu=1.0;inti=1;doublesifenzhipi=0;do{xishu=xishu*(-1);danshu=1.0/(2*i-1);sifenzhipi=sifenzhipi+xishu*danshu;i++;}while(danshu=0.000001);coutsetprecision(15)sifenzhipi*4endl;return0;}2-7//输出斐波那契数列前40个数,以8*5的格式输出#includeiostream#includeiomanipusingnamespacestd;intmain(){intb=2;intfeibo1=0;intfeibo2=1;coutsetw(9)'0'setw(9)'1';for(inti=1;i=38;i++){inta=feibo2;feibo2=feibo1+feibo2;feibo1=a;coutsetw(9)feibo2;b=b+1;if(b%8==0)coutendl;}return0;}2-8//统计输入的元音字母个数#includeiostreamusingnamespacestd;intmain(){charzimu;inta,e,i,o,u;a=e=u=i=o=0;begin:cinzimu;switch(zimu){case'a':a++;break;case'e':e++;break;case'i':i++;break;case'o':o++;break;case'u':u++;break;case'#':gotoend;}gotobegin;end:coutaendleendliendloendluendla+e+i+o+u;return0;}2-10//计算5!+6!+7!#includeiostreamusingnamespacestd;intmain(){inti,j;intsum=0;for(i=5;i=7;i++){intjiecheng=1;for(j=1;j=i;j++)jiecheng=jiecheng*j;sum=sum+jiecheng;}coutsum;return0;}2-11//从2开始100个素数#includeiostreamusingnamespacestd;intmain(){intnum=1;intsushu=0;start:;num++;for(inti=2;i=num;i++){if(num%i==0)break;}if(i==num){coutnumendl;sushu+=1;}if(sushu!=100)gotostart;return0;}2-12//百钱买百鸡问题#includeiostreamusingnamespacestd;intmain(){intx,y,z;for(x=0;x=100;x++){for(y=0;y=100;y++){for(z=0;z=100;z++)if(x+y+z==100&&5*x+3*y+z/3==100&&z%3==0)coutx'\t'y'\t'zendl;}}return0;}2-13#includeiostreamusingnamespacestd;intmain(){inta,b,c,d,e;c=0;cina;cout输入aendl该数的三次方是a个连续奇数;b=1;e=a*a*a;while(c!=e){d=b;c=0;for(inti=1;i=a;i++){c=c+d;d=d+2;}b=b+2;}//coutb-2;intf=b-4;for(intj=1;j=a;j++){f=f+2;coutf'';}cout的和\n;return0;}2-14//输出四方*形状#includeiostreamusingnamespacestd;intmain(){inti,j;for(i=1;i=9;i++){j=1;for(j=1;j=9;j++){if(i+j=6&&i+j=14&&j-i=4&&i-j=4)cout'*';elsecout'';}coutendl;}return0;}3-1-1//向数组a中输入10个整数,求其中的最大值,最小值和10个数的算术平均值#includeiostreamusingnamespacestd;intmain(){inta[10];for(inti=0;i=9;i++)cina[i];intmax=a[0],min=a[0],sum=a[0];for(intj=0;j=9;j++){sum=sum+a[j];max=(maxa[j]?max:a[j]);min=(mina[j]?min:a[j]);}doubleave=sum/10.00;coutmaxendlminendlaveendl;return0;}3-1-2#includeiostreamusingnamespacestd;intmain(){intscore[10];intsum=0,a=0,b=0;for(inti=0;i=9;i++){cinscore[i];sum=sum+score[i];}doubleave=sum/10.0;for(intj=0;j=9;j++){if(score[j]ave)a++;if(score[j]60)b++;}cout成绩大于平均值的人数是aendl成绩小于60的人数bendl;return0;}3-3-1#includeiostreamusingnamespacestd;intmain(){inta[10],sum=0,min,max;doubleave;int*ptoa=a;for(inti=0;i=9;i++){cin*(a+i);sum+=*(a+i);}min=*(a);max=*(a);for(intj=1;j=9;j++){min=(min*(a+j)?min:*(a+j));max=(max*(a+j)?max:*(a+j));}coutmaxendlminendl;ave=sum/10.0;coutaveendl;return0;}3-3-2#includeiostreamusingnamespacestd;intmain(){inta[10],sum=0,j=0,c=0;//定义数组a,sum是各学生成绩之和,j是小于60的个数,c是大于平均值的个数doubleave=0;//定义平均值int*ptoa=a;//使用指针for(inti=0;i=9;i++)//输入并算和,统计小于60的{cin*(ptoa+i);sum+=*(ptoa+i);if(*(ptoa+i)60){j++;}}ave=sum/10.0;//计算平均值//co