电信学院机械二班田文博学号:06131002151.5#includestdio.hvoidmain(){printf(*********************************\n);printf(Verygood!\n);printf(*********************************\n);}1.6#includestdio.hvoidmain(){floatmax(floatx,floaty,floatz);floata,b,c;printf(请分别输入a,b,c:\n);scanf(%f,%f,%f,&a,&b,&c);printf(max=%f,max(a,b,c));}floatmax(floatx,floaty,floatz){floatm,n;m=xy?x:y;n=mz?m:z;return(n);}3.6#includestdio.hvoidmain(){charc1=’a’,c2=’b’,c3=’c’,c4=’\101’,c5=’\116’;printf(“a%cb%c\tc%c\tabc\n”,c1,c2,c3);printf(“\t\b%c%c\n”,c4,c5);}3.9.1#includestdio.hvoidmain(){doublex=2.5,y=4.7,z;inta=7;z=x+a%3*(int)(x+y)%2/4;printf(该表达式的值为:%f,z);}3.9.2#includestdio.hvoidmain(){inta=2,b=3;floatx=3.5,y=2.5,z;z=(float)(a+b)/2+(int)x%(int)y;printf(该表达式的值为:%f,z);}4.5#includestdio.hvoidmain(){inta=5,b=7;doublex=67.8564,y=-789.124;charc='A';longn=1234567;unsignedu=65535;printf(%d%d\n,a,b);printf(%3d%3d\n,a,b);printf(%f,%f\n,x,y);printf(%-10f,%-10f\n,x,y);printf(%8.2f,%8.2f,%.4f,%.4f,%3f,%3f\n,x,y,x,y,x,y);printf(%e,%10.2e\n,x,y);printf(%c,%d,%o,%x\n,n,n,n);printf(%ld,%lo,%x\n,n,n,n);printf(%u,%o,%x,%d\n,u,u,u,u);printf(%s,%5.3s\n,COMPUTER,COMPUTER);}4.6#includestdio.hvoidmain(){inta,b;floatx,y;charc1,c2;scanf(a=%db=%d,&a,&b);scanf(%f%e,&x,&y);scanf(%c%c,&c1,&c2);}4.7#includestdio.hvoidmain(){inta,b;floatx,y,z;charc1,c2;scanf(%5d%5d,&a,&b);scanf(%f%f%*f%f,&x,&y,&z);scanf(%c%c,&c1,&c2);}4.8#includestdio.h#definepi3.14voidmain(){floatr,h,l,s1,s2,v1,v2;printf(请输入r,h的值:\n);scanf(%f,%f,&r,&h);l=2*pi*r;s1=pi*r*r;s2=4*s1;v1=4/3*pi*r*r*r;v2=s1*h;printf(圆周长为:%.2f\n,l);printf(圆面积为:%.2f\n,s1);printf(圆球表面积为:%.2f\n,s2);printf(圆球体积为:%.2f\n,v1);printf(圆柱体积为:%.2f\n,v2);}5.5#includestdio.hvoidmain(){floatx,y;printf(请输入x的值:\n);scanf(%f,&x);if(x1)y=x;elseif(x=1&&x10)y=2*x-1;elsey=3*x-11;printf(x与y的值分别为:\n%f,%f,x,y);printf(\n);}5.6#includestdio.hvoidmain(){floatb;inta;printf(请输入该同学的成绩:\n);scanf(%f,&b);while(b0||b100){printf(输入有误,请重新输入:\n);scanf(%f,&b);}a=int(b/10);if(a6)a=5;switch(a){case10:case9:printf(该同学为等级:A);break;case8:printf(该同学为等级:B);break;case7:printf(该同学为等级:C);break;case6:printf(该同学为等级:D);break;case5:printf(该同学为等级:E);break;}}#includestdio.h#includemath.hvoidmain(){intx,y,m,n,i=1,j=0;printf(请给出一个不多于5位的正整数:\n);scanf(%d,&x);while(x=0||x=100000){printf(输入有误\n请给出一个不多于5位的正整数:\n);scanf(%d,&x);}for(n=0;n5;n++){y=int(x/pow(10,n));if(y0&&y10)m=n+1;}printf(它是%d位数\n,m);printf(从高到低位依次为\n);do{printf(%d,int(x/pow(10,m-i))%10);i++;}while(m-i=0);printf(\n逆序输出为\n);do{printf(%d,int(x/pow(10,j))%10);j++;}while(j-m0);printf(\n);}6.1输入两个正整数m和n,求其最大公约数和最小公倍数。#includestdio.hvoidmain(){intm,n,i,j;printf(请分别输入m,n的值:\n);scanf(%d,%d,&m,&n);for(i=1;i=m;i++){if(m%i==0&&n%i==0)j=i;}printf(这两个整数的最大公约数是:%d,j);for(i=j;;i++){if(i%m==0&&i%n==0)break;}printf(这两个整数的最小公倍数数是:%d,i);printf(\n);}6.2题目:输入一行字符,分别统计出其中英文字母、空格、数字和其他字符的个数。#includestdio.hvoidmain(){inti=0,j=0,k=0,x=0;charc;printf(请输入一行字符串:\n);while((c=getchar())!='\n'){if(c='A'&&c='Z'||c='a'&&c='z')i++;elseif(c=='')j++;elseif(c='0'&&c='9')k++;elsex++;}printf(英文字母、空格、数字、其他字符的个数分别为:%d,%d,%d,%d,,i,j,k,x);printf(\n);}6.3求Sn=a+aa+aaa+…+aa…a之值,其中a是一个数字。例如:2+22+222+2222+22222(此时n=5),n由键盘输入。#includestdio.h#includemath.hvoidmain(){inti,n;intsum=0,s=0;printf(请输入n的值:\n);scanf(%d,&n);while(n1){printf(请重新输入n的值:\n);scanf(%d,&n);}for(i=0;in;i++){s+=pow(10,i);sum+=2*s;}printf(sum=%d\n,sum);}6.8题目:有一分数序列2/1,3/2,5/3,8/5,13/8,21/13,…求出这个数列的前20项之和。#includestdio.hvoidmain(){inta=1,b=1,i;floatsum=0.0;for(i=0;i20;i++){a=a+b;b=a-b;sum+=(float)a/b;}printf(这个数列前二十项之和为:\n%f,sum);printf(\n);}7.2#includestdio.hvoidmain(){inti,j,t,a[10];printf(请输入十个整数:\n);for(i=0;i10;i++){scanf(%d,&a[i]);}for(j=1;j10;j++)for(i=0;i10-j;i++)if(a[i]a[i+1]){t=a[i];a[i]=a[i+1];a[i+1]=t;}printf(这十位数从大到小排列为:\n);for(i=0;i10;i++)printf(%5d,a[i]);printf(\n);}7.3#includestdio.hvoidmain(){inti,j,m,n,a[3][3];printf(请输入3*3的整形矩阵\n);for(i=0;i3;i++)for(j=0;j3;j++)scanf(%d,&a[i][j]);m=a[0][0]+a[1][1]+a[2][2];n=a[0][2]+a[1][1]+a[2][0];printf(3*3的整形矩阵对角线元素之和为:\n);printf(%d,%d,m,n);}7.4#includestdio.hvoidmain(){staticinta[10]={1,5,6,10,20,24,55,58,64};inti,t;printf(请输入一个数:\n);scanf(%d,&a[9]);for(i=9;i0;i--)if(a[i]a[i-1]){t=a[i-1];a[i-1]=a[i];a[i]=t;}for(i=0;i10;i++)printf(%4d,a[i]);printf(\n);}7.8#includestdio.hvoidmain(){inta[5][5],b[5],c[5],d[5][5];inti,j,k,l;printf(请输入5*5的整型数组\n);for(i=0;i5;i++)for(j=0;j5;j++)scanf(%d,&d[i][j]);for(i=0;i5;i++)for(j=0;j5;j++)a[i][j]=d[i][j];for(i=0,k=0;i5;i++,k++)for(j=0;j4;j++){if(a[i][j]=a[i][j+1])b[k]=a[i][j+1]=a[i][j];elseb[k]=a[i][j+1];}for(j=0,l=0;j5;j++,l++)for(i=0;i4;i++){if(a[i][j]=a[i+1][j])c[l]=a[i+1][j]=a[i][j];elsec[l]=a[i+1][j];}for(i=0,k=0;i5;i++,k++)for(j=0,l=0;j5;j++,l++)if(d[i][j]-b[k]==0){if(d[i][j]-c[l]==0)printf(鞍点为d[%d][%d]=%d\n,i,j,d[i][j]);elseprintf(没有鞍点\n);}}7.10#includestdio.h#includestring.hvoidmain(){inti,j=0,k=0,l=0,m=0,n=0;charstr0[301],str1[100],str2[100],str3[100];gets(str1);gets(str2);gets(str3);strcat(str0,str1);strcat(str0,str2);strcat(str0,str