C语言万年历查询系统
发布网友
发布时间:2022-04-24 17:05
我来回答
共1个回答
热心网友
时间:2023-10-24 16:24
/* welcome to use the WanNianLi system! */
#include<stdio.h>
#include<stdlib.h>
char* month_str[]={"January","February","March","April","May","June","July","August","September","October","November","December"};
char* week[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
int IsLeapYear(int year) /*find out the year is leap year or not*/
{
if((year%4==0&&year%100!=0)||(year%400==0))
return 1;
else
return 0;
}
int month_day(int year,int month)
{
int mon_day[]={31,28,31,30,31,30,31,31,30,31,30,31};
if(IsLeapYear(year)&&month==2)
return 29;
else
return(mon_day[month-1]);
}
int DaySearch(int year,int month,int day) /*search what day this day is*/
{
int c=0;
float s;
int m;
for(m=1;m<month;m++)
c=c+month_day(year,m);
c=c+day;
s=year-1+(float)(year-1)/4+(float)(year-1)/100+(float)(year-1)/400-40+c;
return ((int)s%7);
}
int PrintAllYear(int year)/*print the all year*/
{
int temp;
int i,j;
printf("\n\n%d Calander\n",year);
for(i=1;i<=12;i++)
{
printf("\n\n%s(%d)\n",month_str[i-1],i);
printf("0 1 2 3 4 5 6 \n");
printf("S M T W T F S \n\n");
temp=DaySearch(year,i,1);
for(j=1;j<=month_day(year,i)+temp;j++)
{
if(j-temp<=0)
printf(" ");
else if(j-temp<10)
printf("%d ",j-temp);
else
printf("%d ",j-temp);
if(j%7==0)
printf("\n");
}
}
return 0;
}
int main()
{
int option,da;
char ch;
int year,month,day;
printf("Copyright @ 2005 TianQian All rights reserved!:):):)");
printf("\n\nWelcome to use the WanNianLi system!\n");
while(1)
{
printf("\nPlease select the service you need:\n");
printf("\n1 Search what day the day is");
printf("\n2 Search whether the year is leap year or not");
printf("\n3 Print the calander of the whole year");
printf("\n4 Exit\n");
scanf("%d",&option);
switch(option)
{
case 1:
while(1)
{
printf("\nPlease input the year,month and day(XXXX,XX,XX):");
scanf("%d,%d,%d,%c",&year,&month,&day);
da=DaySearch(year,month,day);
printf("\n%d-%d-%d is %s,do you want to continue?(Y/N)",year,month,day,week[da]);
fflush(stdin);
scanf("%c",&ch);
if(ch=='N'||ch=='n')
break;
}
break;
case 2:
while(1)
{
printf("\nPlease input the year which needs searched?(XXXX)");
scanf("%d",&year);
if(IsLeapYear(year))
printf("\n%d is Leap year,do you want to continue?(Y/N)",year);
else
printf("\n%d is not Leap year,do you want to continue(Y/N)?",year);
fflush(stdin);
scanf("%c",&ch);
if(ch=='N'||ch=='n')
break;
}
break;
case 3:
while(1)
{
printf("\nPlease input the year which needs printed(XXXX)");
scanf("%d",&year);
PrintAllYear(year);
printf("\nDo you want to continue to print(Y/N)?");
fflush(stdin);
scanf("%c",&ch);
if(ch=='N'||ch=='n')
break;
}
break;
case 4:
fflush(stdin);
printf("Are you sure?(Y/N)");
scanf("%c",&ch);
if(ch=='Y'||ch=='y')
exit(0);
break;
default:
printf("\nError:Sorry,there is no this service now!\n");
break;
}
}
return 0;
}
用C语言编写万年历系统
/*根据系统日期输出星期函数*/void printWeek(){ int day ; /*根据系统日期获得星期*/ day=getWeek(currentYear,currentMonth,currentDay); textcolor(11); /*输出星期,0表示星期天,1表示星期一...6表示星期六*/ if(day==0) cprintf("%d-%d-%d,Sunday!",currentYear,currentMonth,currentDay); if(day=...
C语言程序设计 万年历查询程序。
1. 画出程序流程图;2. 编写程序;3. 调试程序,对调试过程中出现的问题进行分析,找出错误的原因并予改正;4. 写出通过调试并修改正确的原程序。【要求】:1. 程序运行后,首先在屏幕上显示主菜单:1. 查询某年某月某日是星期几 2. 查询某年是否是闰年 3. 打印某年的全年日历 4. 退出...
电子万年历: 用C语言设计一个年历系统
long int f(int year,int month){/*f(年,月)=年-1,如月<3;否则,f(年,月)=年*/ if(month<3) return year-1;else return year;} long int g(int month){/*g(月)=月+13,如月<3;否则,g(月)=月+1*/ if(month<3) return month+13;else return month+1;} long int...
跪求C语言万年历程序设计
int month_day[]={31,28,31,30,31,30,31,31,30,31,30,31};printf("您好!!!\n\n欢迎使用万年历系统!\n");timer=time(0);timenow=localtime(&timer);printf("\n现在的时间是:%d年 %d月 %d日 %d时 %d分",(*timenow).tm_year+1900,(*timenow).tm_mon+1,(*timenow).tm_mda...
万年历查询程序. C语言代码
typedef struct seqlist{TpList list;int num;char *place;}TSeqList,*pTSeqList;TpList list_init(int num);void list_read(pTSeqList p);void list_sort(TpList p,int len);TpList list_init(int num){TpList p=(TpList)malloc(sizeof(ElemType)*num);if(!p){printf("Fail!"...
用c语言编写万年历,要求输出任意一年的某月,能显示出这个月的日历_百度...
1、首先要判断一个年份是闰年还是平年,用一个子程序来做。2、然后就开始写主程序,首先用scanf得到一个年份。3、在判断这个年份是平年还是闰年后用printf在CMD中打印出来。4、在编写完成后,在Notepad++界面下按下F5,弹出输入框。5、cmd /k gcc -o "$(CURRENT_DIRECTORY)\$(NAME_PART).exe""$...
C语言万年历代码
printf(" C语言简单万年历\n"); //打印标题 XunHuan: //循环标号(可以通过goto跳转到这里)printf("请输入年份<0000~9999>: "); //提示输入年份(0~9999)scanf("%d",&Year); //把输入的年份赋值给变量Year printf("请输入月份<0~12>: "); //提示输入月份(1~12)scanf("...
c语言万年历程序,要求输入一个年份,打印出该年年历,要求三个月并排输出...
printf("请输入要查询的年月日\nyear month day\n");scanf("%d %d %d",&year,&mon,&day);if(year<0 || mon<0 || mon>12 || day<0 || day>31){ system("cls");printf("输入的年月日不正确,请重新输入!");Sleep(3000);look_week();} C=judge_week(year,mon,day);S=...
用c语言编写万年历
INT MD(INT M,INT Y); /*返回本月的天数*/ VOID PRTWEEK(VOID); /*输出表头*/ INT FW(INT M,INT Y); /*返回本月一号是星期几*/ VOID PRTMONTH(INT M); /*输出月份表头*/ INT MAIN(VOID){ INT Y,M,I,TEST,WEEK;PRINTF("PLEASE IMPORT YEAR OF YOU WANT TO SELECT : ");SCA...
c语言编程“万年历”:输入年份后输入这一年元旦是周几然后出现这一年的...
c=c+month_day(year,m);c=c+day;s=year-1+(float)(year-1)/4+(float)(year-1)/100+(float)(year-1)/400-40+c;return ((int)s%7);} int PrintAllYear(int year){ int temp;int i,j;printf("\n\n%d year\n",year);for(i=1;i<=12;i++){ temp=DaySearch(year,i,1...