资源描述:
《万年历程序设计c语言代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、这是当时我做的一个小小的课题,希望对你有所帮助#include"stdio.h"/*RequiredforMS-DOSuse*/#defineENTER0x1C0D/*Enterkey*/intyear,month,day;staticchar*days[8]={"","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};structTIMEDATE{intyear;/*year1980..2099*/intmonth;/*month1=J
2、an2=Feb,etc.*/intday;/*dayofmonth0..31*/inthours;/*hour0..23*/intminutes;/*minute0..59*/intseconds;/*second0..59*/inthsecs;/*1/100thsofsecond0..99*/chardateline[47];/*date&timetogether*/};staticstructTIMEDATEtoday;main(){charcmonth[3];charcday[3];charcyear[5];doubleg
3、etdays();doubledaynumb,numbnow;intweekday,retcode,dayer,i;dayer=datetime(&today);clrscn();for(i=0;i<3;++i)cmonth[i]=' ';for(i=0;i<3;++i)cday[i]=' ';for(i=0;i<5;++i)cyear[i]=' ';putstr(5,8,14,"EnterdateinMMDDYYYYformat:");while(retcode!=ENTER){retcode=bufinp(5,41,1
4、3,2,cmonth);if(retcode!=ENTER)retcode=bufinp(5,44,13,2,cday);if(retcode!=ENTER)retcode=bufinp(5,47,13,4,cyear);}year=atoi(&cyear);month=atoi(&cmonth);day=atoi(&cday);daynumb=getdays(year,month,day);numbnow=getdays(today.year,today.month,today.day);weekday=weekdays(da
5、ynumb);if(numbnow-daynumb==0)printf("%02d-%02d-%dis",month,day,year);if(numbnow-daynumb>0)printf("%02d-%02d-%dwas",month,day,year);if(numbnow-daynumb<0)printf("%02d-%02d-%dwillbe",month,day,year);printf("a%s",days[weekday]);}/*endMAIN*//****************
6、*********************************************GETDAYS-Fromintegervaluesofyear(YYYY),month**(MM)andday(DD)thissubroutinereturnsa**doublefloatnumberwhichrepresentsthe**numberofdayssinceJan1,1980(day1).**ThisroutineistheoppositeofGETDATE.*********************************
7、****************************/doublegetdays(year,month,day)intyear,month,day;{inty,m;doublea,b,d,daynumb;doublefloor(),intg();/************************************makecorrectionfornoyear0************************************/if(year<0)y=year+1;elsey=year;/*************
8、**********************************************JanandFebaremonths13and14inthiscalculation*******************************************