2、])printf("%d",num[i]);return0;}输出时分秒#includemain(){intx,s,t,d;scanf("%d",&x);s=x%60;t=(x/60)%60;d=(x/60)/60;printf("%d时%d分%d秒",d,t,s);}三个数的交换#includevoidmain(){inta,b,c,t;scanf("%d%d%d",&a,&b,&c);printf("Theoriginalnumber:a=%d,b=%d,c=%d",a,b,c);
3、t=a,a=b,b=t;t=a,a=c,c=t;printf("afterswap:a=%d,b=%d,c=%d",a,b,c);}switch语句的运用#includemain(){inta,m;printf("pleaseinputanumber:");scanf("%d",&a);switch(a/10){case10:case9:m=5;break;case8:m=4;break;case7:m=3;break;case6:m=2;break;default:m=1;}printf("m=%d",m
4、);}判断奇数和偶数#includemain(){intx;printf("Pleaseinputanumber:");scanf("%d",&x);if(x%2==0)printf("thisisaoushu!");elseprintf("thisisajishu!");}小写改大写,若是大写则不变includemain(){charc1,c2;printf("Inputaletter");scanf("%c",&c1);c2=('a'<=c1&&c1<='z')?(c1-'a'+'
5、A'):c1;printf("%c",c2);getchar();return0;}输入一个数,输出这个数是几位数#includemain(){intx,n;printf("pleaseinputanumber:");scanf("%d",&x);n=0;while(x!=0){x=x/10;n++;}printf("%d",n);}输入一个数,判断它是几位数,然后逆序输出#includeintmain(){intnum;intlen=0;inttemp=0;printf("Pleasei
6、nputanumber:");scanf("%d",&num);while((num%10)!=0){temp=temp*10+(num%10);len++;num=num/10;}printf("length=%d",len);printf("Reverseis%d",temp);}打印水仙花数#includemain(){intx,a,b,c;for(x=100;x<=999;x++){a=x%10;b=(x/10)%10;c=x/100;if(x==a*a*a+b*b*b+c*c*c){pri
7、ntf("%5d",x);}}printf("");}判断闰年#include"stdio.h"main(){intk,flag,n=0;for(k=1980;k<=2880;k++){flag=(k%4==0)&&(k%100!=0)
8、
9、(k%400==0);if(flag){printf("%5d",k);n++;if(n%10==0)printf("");}}printf("");}求1-3+5-7...-99+101的值#includemain(){intsum,i,t;sum=1;t=
10、1;for(i=3;i<=101;i=i+2){t=-t;sum=sum+t*i;}printf("sum=%d",sum);}求前n项和#includemain(){floats,t;intn,i,fz,fm;s=0;fz=2;fm=1;printf("Entern:"