画这个程序的NS流程图,万分感谢~~~!!!#includeintleap(intyear){if(year%4==0&&year%100!=0||year%400==0)/*判断是否是闰年*/return1;elsereturn0;}intdays_month(intmo...
画这个程序的NS流程图,万分感谢~~~!!!
#include
int leap (int year)
{if(year%4==0&&year%100!=0||year%400==0) /*判断是否是闰年*/
return 1;
else return 0;
}
int days_month (int month,int year) /*判断大月和小月*/
{
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12) /*找出大月*/
return 31;
if(month==4||month==6||month==9||month==11) /*找出小月*/
return 30;
if(month==2&&leap(year)==1) return 29; /*判断二月是28天还是29天*/
else return 28;
}
int firstday(int month,int year)
{int w;
w=(1+2*month+3*(month+1)/5+year+year/4+year/400-year/100)%7+1; /*判断每个月开始的第一天是星期几*/
return w;
}
main()
{int i,j=1,k=1,a,b,month,year;
printf("\n input month and year:\n");
scanf("%d%d",&month,&year); /*输入月和年*/
b=days_month(month,year);
a=firstday (month,year);
printf(" Sun Mon Tue Wed Thu Fri Sat \n"); /*输出对应当月的日历*/
if(a==7)
{for(i=1;i<=b;i++)
{printf("%4d",i);
if(i%7==0)
{printf("\n");
}
}
}
if(a!=7)
{while (j<=4*a)
{printf(" ");
j++;
}
for(i=1;i<=b;i++)
{printf("%4d",i);
if(i==7*k-a)
{printf("\n");
k++;
}
}
}
printf("\n");
}
发到我邮箱也行啊yueyuezy@qq.com
展开