1、1、编程实现:从键盘输入 3 个变量的值,其中中 a=5,b=6,c=7,然后将 3 个变量的值进行交换,使得 a=6,b=7,c=5.#include“stdio.h“void main()int a,b,c,m;printf(“Enter a,b,c:“);scanf(“%d,%d,%d“,m=a;a=b;b=c;c=m;printf(“a=%d,b=%d,c=%dn“,a,b,c);2、编程实现:输入任意一个 3 位数,将其各位数字反序输出(例如:输入 123,输出 321) 。#include“stdio.h“void main()int a,b,c,x,y;printf(“输入一个
2、3 位数: n“);scanf(“%d“,a=x%10;b=x/100;c=x%100/10;y=a*100+c*10+b;printf(“%dn“,y);3、编程实现:输入三角形的边长,求三角形面积(面积=sqrt(s(s-a)(s-b)(s-c) ) , s=(a+b+c)/2.#include#includevoid main()int a,b,c;float x,y;scanf(“%d,%d,%d“,x=(a+b+c)/2;y=sqrt(s*(s-a)*(s-b)*(s-c);printf(“%.3fn“,y);4、编程实现:从键盘上输入一个年月日,要求出该天是该年的第几天(注意判断该
3、年是否是闰年) 。#includevoid main()inta,b,c;printf(“输入一个年月日:“);scanf(“%d%d%d“,if(a%4=0|a%100=0)switch(b)case 1: printf(“%dn“,c);break;case 2: printf(“%dn“,31+c);break;case 3: printf(“%dn“,60+c);break;case 4:printf(“%dn“,91+c);break;case 5:printf(“%dn“,121+c);break;case 6:printf(“%dn“,152+c);break;case 7:pr
4、intf(“%dn“,182+c);break;case 8:printf(“%dn“,213+c);break;case 9: printf(“%dn“,244+c);break;case 10: printf(“%dn“,274+c);break;case 11: printf(“%dn“,305+c);break;case 12: printf(“%dn“,335+c);break;elseswitch(b)case 1: printf(“%dn“,c);break;case 2: printf(“%dn“,31+c);break;case 3: printf(“%dn“,59+c);b
5、reak;case 4: printf(“%dn“,90+c);break;case 5: printf(“%dn“,120c);break;case 6: printf(“%dn“,151+c);break;case 7: printf(“%dn“,181+c);break;case 8: printf(“%dn“,212+c);break;case 9: printf(“%dn“,243+c);break;case 10: printf(“%dn“,273+c);break;case 11: printf(“%dn“,304+c);break;case 12: printf(“%dn“,334+c);break;5、求n!(1!+2!+3!+.+25!)。 (n 从 1 到 25)#includevoid main()float sum=1,term=0;for(i=1;iint f(int,a);void main()int a,y;scanf(“%d“,if(avoid main()int i,m,a10;for(i=0;iai+1)m=ai;ai=ai+1;ai+1=m;for(i=0;iat-,h+)if(*h!=*t)break; return t=h;