资源描述:
《云南大学软件学院C语言实验日期问题.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#includeintv[12];intvr[12];intrunnian(inty){intt;t=0;if(((y%4==0)&&(y%100!=0))
2、
3、(y%400==0))t=1;returnt;}voidone(){inti,j,k,l,m,d,y;printf("yearmonthday");scanf("%d%d%d",&y,&m,&d);if(runnian(y)==0){printf("%d",v[m-1]+d);}else{printf("%d",vr[m-1]+d);}}voidtwo(){inti,j,k,l,m,d
4、,y;printf("yeardays");scanf("%d%d",&y,&d);if(runnian(y)==0){for(i=1;i<=12;i++)if((v[i-1]=d)){printf("%d%d%d",y,i,d-v[i-1]);}}else{for(i=1;i<=12;i++){if((vr[i-1]=d))printf("%d%d%d",y,i,d-vr[i-1]);}}}voidmain(){inta;v[0]=vr[0]=0;v[1]=31;vr[1]=31;v[2]=28+v[1];vr[
5、2]=vr[1]+29;v[3]=31+v[2];vr[3]=vr[2]+31;v[4]=30+v[3];vr[4]=vr[3]+30;v[5]=31+v[4];vr[5]=vr[4]+31;v[6]=30+v[5];vr[6]=vr[5]+30;v[7]=31+v[6];vr[7]=vr[6]+31;v[8]=31+v[7];vr[8]=vr[7]+31;v[9]=30+v[8];vr[9]=vr[8]+30;v[10]=31+v[9];vr[10]=vr[9]+31;v[11]=30+v[10];vr[11]=vr[10]+30;v[12]=31+v[11];vr[1
6、2]=vr[11]+31;printf("1or2");scanf("%d",&a);if(a==1)one();elsetwo();}#includeintmain(){intn,k;inta,b;scanf("%d",&n);if(n<=2)printf("%d",n);else{a=1;b=2;k=3;while(k<=n){a=b;b=b*k;k++;}printf("%d",b);}return0;}#includeintmax;inteat(inttemp,intn){intall;all=1;if(n>1){t
7、emp++;temp=temp+temp;eat(temp,n-1);return0;}if(n=1)max=temp;}intmain(){inti,j,k,l,n;eat(1,10);printf("%d",max);return0;}#includeintmain(){intn,result;intfactorial(int);printf("inputanumber:");scanf("%d",&n);result=factorial(n);printf("thefactorialof%dis%d",n,result);retur
8、n0;}intfactorial(intn){if(n==0)return(1);elsereturn(n*factorial(n-1));}