运行出错!高手速来!
程序代码:
#include<stdio.h> int main() {printf(" 万年历by\n"); void abc( int year,int month); int year,month; for(;;) {printf("请输入要查询的年份和月份\n"); printf("年份:"); scanf("%d",&year); printf("月份:"); scanf("%d"); for(;;) if(year>0&&(1<=month&&month<=12))break; else{printf("请输入正确的年份和月份"); printf("年份:"); scanf("%d\n",&year); printf("月份:"); scanf("%d\n");} abc(year,month); return 0; } } void abc(int year,int month) {int preyear;int premonth;int predays;int days; int leap;int i; preyear=year-1; premonth=month-1; leap=((year%4&&year%100!=0)||(year%400==0))?1:0; predays=preyear*365+preyear/4+preyear/400-preyear/100; switch(premonth) {case 1:predays+=31;break; case 2:predays+=59;break; case 3:predays+=90;break; case 4:predays+=120;break; case 5:predays+=151;break; case 6:predays+=181;break; case 7:predays+=212;break; case 8:predays+=243;break; case 9:predays+=273;break; case 10:predays+=304;break; case 11:predays+=334;break; } if(leap&&month>=3)predays++; switch(month) {case 1:days=31;printf("1月 ");break; case 2:days=29;printf("2月 ");break; case 3:days=31;printf("3月 ");break; case 4:days=30;printf("4月 ");break; case 5:days=31;printf("5月 ");break; case 6:days=30;printf("6月 ");break; case 7:days=31;printf("7月 ");break; case 8:days=31;printf("8月 ");break; case 9:days=30;printf("9月 ");break; case 10:days=31;printf("10月 ");break; case 11:days=30;printf("11月 ");break; case 12:days=31;printf("12月 ");break; } if(leap&&month==2)days=28; printf("%d",year); if(leap)printf("闰年\n"); printf("日 一 二 三 四 五 六\n"); predays%=7; for(i=1;i<=predays;i++) printf(" "); for(i=1;i<=days;i++) {printf("%2d",i); if((i+predays)%7==6)printf("\n"); } printf("\n"); }可以运行但是问题是下面的图。每次运行都这样!纠结啊!求高手解释啊!
[ 本帖最后由 唏嘘草 于 2011-6-6 15:11 编辑 ]