1、5.2#includevoid main()int a,b,c,num,n;printf(“请输入一个三位数:n“);scanf(“%d“,c=num%10;b=(num/10)%10;a=num/100;if(a=belse if(a=celse if(b=celse n=0;if(n)printf(“%dn“,num);5.3#include#includevoid main()int x;double y;scanf(“%d“, /*输入 x*/switch(x/10)case 0:y=cos(x+3.0);break;case 1:y=pow(cos(x+7.5),2);break;c
2、ase 2:y=pow(cos(x+4.0),4);break;printf(“%lfn“,y);5.4#includevoid main()int num,i,leap;scanf(“%d“,if(num%2!=0)printf(“是奇数n“);if(num1)for(i=2;ivoid main()int a,b,c,i,n;for(i=0;i#includevoid main()double m=1.0,p=0.0;int k=1,n=1;dom=1.0/n;n=n+2;if(k%2=0)m=(-1.0)*m;p=p+m;k+;while(fabs(m)=1e-6);p=p*4.0;pr
3、intf(“%lfn“,p);6.2#includevoid main()int k,k1=1,k2=1,k3;float p=0,m;for(k=1;kvoid main()int i,j,k; for(i=0;ivoid main()int i,j,k;char c=65; for(i=0;ivoid main()int a,b,i,n;for(a=1;a#includevoid main()int num,a,b,c,p;for(num=100;numvoid main()int m,i,n;for(i=2;i#includevoid main()int i,a,b;for(i=1000
4、;ivoid main()int i,a,b,c;for(i=100;ivoid main()int i,n=1,m;for(i=1;ivoid main() int long a;char h16; int i; scanf(“%ld“, i=15;while(a) int x=a%16; if(xint main()int num,a10,m; int i=0,j,flag=1; scanf(“%d“, do m=num%10;ai=m;num=num/10; i+; while (num%10!=0); for (j=0,i-;i=j;i-,j+) if (aj=ai)continue;
5、else flag=0; break; if (flag) printf(“是回文n“); else printf(“不是回文n“);return 0;7.3#includevoid main()int i,j,max,row=0,column=0;int a34=1,3,5,7,2,6,8,9,11,22,33,10;max=a00;for(i=0;imax)max=aij;row=i;column=j;printf(“max=%d,row=%d,column=%dn“,max,row,column);7.4#includevoid main()int f10=1,1;int i,pow=0
6、;for(i=2;ivoid main()int i,j;int a88;for(i=0;i#includevoid main()int i,m;char a100,b100;gets(a);gets(b);if(strcmp(a,b)!=0)if(strlen(a)strlen(b)strcat(a,b);puts(a);elsestrcat(b,a);puts(b);8.1#include void Fun(int a) char h16; int i; i=15;while(a) int x=a%16; if(xvoid strcpy(char *c, char *d) int i=0;
7、while(*(d+i)!=0)*(c+i)=*(d+i);i+;*(c+i)=0;void main()char a100,b100;printf(“输入一个字符串:“);gets(b); strcpy(a,b);printf(“复制后的字符串:%sn“,a);/(2.字符串的连接)/#includevoid strcat(char *c,char *d)while(*c!=0)c+;while(*d!=0)*c=*d; c+; d+;*c=0;void main()char a100,b100;printf(“分别输入字符串 a 和 b:n“);gets(a);gets(b);strcat
8、(a,b);printf(“连接后的字符串:n“);puts(a);/(3.字符串小写字母改为大写字母)/#includevoid strupr(char a100)int i;for(i=0;i=97for(i=0;i=65d+;if(*c=*d)return 0;else if(*c*d)return 1;elsereturn -1;void main()char a100,b100;printf(“分别输入两个字符串 a 和b:n“);gets(a);gets(b);if(strcmp(a,b)=0)printf(“相等n“);else if(strcmp(a,b)=1)printf(“
9、不等,且 abn“);elseprintf(“不等,且 ban“);8.7#include#includefloat A(float a,float b,float c)float s;s=(a+b+c)/2.0;return(s);float B(float a,float b,float c)float area,s;s=A(a,b,c);area=sqrt(s*(s-a)*(s-b)*(s-c);return(area);void main()float a,b,c,area,s,p;printf(“输入三边长 a,b,c:n“);scanf(“%f%f%f“,if(a+b#includ
10、eint fun(int x)int i,m=1;for(i=1;i#includevoid fun(char a)char i,m,n;n=i=strlen(a);while(i3)i=i-3;for(m=n;mi;m-)am=am-1;ai=,;n+;void main()static char a20;printf(“输入数字:n“);gets(a);fun(a);puts(a);8.14#include#includelong fun(char *a)int i=1,x,y;long m=0;x=strlen(a);if(a0=-)y=-1;x-;a+;else y=1;while(*a)m=m*10-48+(*a+);return(m*y);void main()char a100;long n;printf(“输入纯数字字符串:n“);gets(a);n=fun(a);printf(“%ldn“,n);