点击这里给我发消息 点击这里给我发消息

实例编程:用C语言编的一个日历

添加时间:2013-12-7
    相关阅读: C语言

 #include <sio.h>
#include<conio.h>
#include<slib.h>
int IsLeapYear(int);
void main()
{
int i;
int day;
int year;
int temp;
int temp_i;
long int Year_days = 0;
int Year_Start = 1;
int Per_Year_Days;
int month_day[]={31,28,31,30,31,30,31,31,30,31,30,31,29};

printf("Please enter the year: ");
scanf("%d",&year);

while(Year_Start < year)
{
if( IsLeapYear( Year_Start ) )
Per_Year_Days = 366;
else
Per_Year_Days = 365;

Year_days = Year_days Per_Year_Days;
Year_Start ;
}

for( temp = 1; temp <=12; temp )
{
switch( temp )
{
case 1:
printf(" January(%d)\n",year);
break;
case 2:
printf(" February(%d)\n",year);
break;
case 3:
printf(" March(%d)\n",year);
break;
case 4:
printf(" April(%d)\n",year);
break;
case 5:
printf(" May(%d)\n",year);
break;
case 6:
printf(" June(%d)\n",year);
break;
case 7:
printf(" July(%d)\n",year);
break;
case 8:
printf(" August(%d)\n",year);
break;
case 9:
printf(" September(%d)\n",year);
break;
case 10:
printf(" October(%d)\n",year);
break;
case 11:
printf(" November(%d)\n",year);
break;
case 12:
printf(" December(%d)\n",year);
break;
}
i = Year_days % 7;
printf("Mon Tue Wed Thu Fri Sat Sun\n");
if( i != 0 )
for( temp_i = 0; temp_i < i; temp_i )
printf(" ");
day = 1;
if( IsLeapYear(year) && temp == 2)
while( day <= month_day[12] )
{
if( day >1 )
if( Year_days % 7 == 0 )
printf("\n");
if( day >= 10 )
printf("%d ",day);
else
printf("%d ",day);
Year_days ;
day ;
}

else
while (day <= month_day[temp-1])
{
if( day > 1 )
if( Year_days % 7 == 0 )
printf("\n");
if( day >=10 )
printf("%d ",day);
else
printf("%d ",day);
Year_days ;
day ;
}
printf("\n");
if( getch() == 'q' )
exit(0);
}
getch();
}


int IsLeapYear( int year )
{
if ((year %4 == 0) && (year % 100 != 0) ||
(year % 400 == 0) )
return 1;
else
return 0;
}

相关实例编程:用C语言编的一个日历

咨询热线:020-85648757 85648755 85648616 0755-27912581 客服:020-85648756 0755-27912581 业务传真:020-32579052
广州市网景网络科技有限公司 Copyright◎2003-2008 Veelink.com. All Rights Reserved.
广州商务地址:广东省广州市黄埔大道中203号(海景园区)海景花园C栋501室
= 深圳商务地址:深圳市宝源路华丰宝源大厦606
研发中心:广东广州市天河软件园海景园区 粤ICP备05103322号 工商注册