实践课题--万年历(按enter显示下个月份)

问题及代码:

/*
*copyright (t) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称:test.cpp
*作者:张晴晴
*完成日期:2016年6月30日
*版本号:v1.0
*问题描述:万年历(2)
*输入描述:输入年份
*程序输出:输出一年的月历先输出1月按enter再输出二月
*/


#include
int judge(int year,int month)/*定义一个函数,把月分为四类(28,29,30,31)*/
{
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
return(1);/*31天的月份返回值为1*/
else if(month==2)
{
if(year%4!=0||year%100==0&&year%400!=0)
return(2);/*平年的2月份返回值为2*/
else return(3);/*闰年的2月份,返回值为3*/
}
else return(4);/*30天的月份,返回值为4*/
}

int main()

{
void show();
int year,i,j,a,n,m,k;
char ** p;
char enter;
char * week[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
char*month[]={"January","February","March","April","May","June","July","August","September","October","November","December"};
show();
printf("请输入你要查询的年:");
while(scanf("%d",&year)!=EOF)
{
printf("\n");
printf(" %d的日历\n",year);
printf("----------------------------------------------");
printf("\n");
a=(year+(year-1)/4-(year-1)/100+(year-1)/400)%7;
for(i=0;scanf("%c",&enter)!=27;i++)/*输出前几个月的日历表*/
{
n=judge(year,i+1);
p=month+i;
printf("%s\n",*p);
printf("\n");
for(j=0;j<7;j++)
{p=week+j;
printf("%6s",*p);}
printf("\n");
for(k=0;k

运行结果:

实践课题--万年历(按enter显示下个月份)_第1张图片

你可能感兴趣的:(技术支持实训项目)