求一个日历系统的C语言课程设计 C语言课程设计-万年历

作者&投稿:谏卓 (若有异议请与网页底部的电邮联系)
#include <stdio.h>
#include <windows.h>
int week(int y,int m,int d);
void main()
{
int monthday[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int y,w,i,m=1,d=1;
printf("请输入一个年份yyyy:\n");
scanf("%d",&y);
if (y%4==0&&y%100!=0) monthday[1]=29;

for(m=1;m<=12;m++)
{

printf("\n %d年,%d月\n",y,m);
printf("S M T W T F S \n");

for (d=1;d<=monthday[m-1];d++)
{
w=week(y,m,d);
if(d==1)
{
for (i=0;i<w;i++) printf(" ");
}

if(d<10) printf("%d ",d);
else printf("%d ",d);

if(w==6) printf(" \n");
}

}
scanf("%d",&y);
}
int week (int y,int m,int d)
{
int w;
if((m==1)||(m==2))
{
y--;
m+=12;
}
w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400+1)%7;
return (w);
}

没有阴历
因为阴历没用什么固定规则
呵呵

急求: C语言课程设计 日历查询系统~

#include "stdio.h" /* Required for MS-DOS use */
#define ENTER 0x1C0D /* Enter key */
int year, month, day;
static char *days[8] = {" ","Sunday ","Monday ","Tuesday ",
"Wednesday","Thursday ","Friday ","Saturday "};
struct TIMEDATE {
int year; /* year 1980..2099 */
int month; /* month 1=Jan 2=Feb, etc. */
int day; /* day of month 0..31 */
int hours; /* hour 0..23 */
int minutes; /* minute 0..59 */
int seconds; /* second 0..59 */
int hsecs; /* 1/100ths of second 0..99 */
char dateline[47]; /* date & time together */
};
static struct TIMEDATE today;
main()
{
char cmonth[3];
char cday[3];
char cyear[5];
double getdays();
double daynumb, numbnow;
int weekday, retcode, dayer, i;
dayer = datetime(&today);
clrscn();
for (i=0;i<3;++i)cmonth[i]='\0';
for (i=0;i<3;++i)cday[i]='\0';
for (i=0;i<5;++i)cyear[i]='\0';
putstr(5,8,14,"Enter date in MM DD YYYY format:");
while (retcode != ENTER)
{
retcode = bufinp(5,41,13,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(daynumb);
if (numbnow - daynumb == 0)
printf("

%02d-%02d-%d is",month, day, year);
if (numbnow - daynumb > 0)
printf("

%02d-%02d-%d was",month, day, year);
if (numbnow - daynumb < 0)
printf("

%02d-%02d-%d will be",month, day, year);
printf(" a %s
",days[weekday]);
} /* end MAIN */
/************************************************************
* GETDAYS - From integer values of year (YYYY), month *
* (MM) and day (DD) this subroutine returns a *
* double float number which represents the *
* number of days since Jan 1, 1980 (day 1). *
* This routine is the opposite of GETDATE. *
************************************************************/
double getdays(year, month, day)
int year, month, day;
{
int y,m;
double a,b,d, daynumb;
double floor(),intg();
/**********************************
** make correction for no year 0 **
**********************************/
if (year < 0) y = year + 1;
else y = year;
/*********************************************************
** Jan and Feb are months 13 and 14 in this calculation **
*********************************************************/
m = month;
if (month < 3)
{
m = m + 12;
y = y - 1;
}
/**************************
** calculate Julian days **
**************************/
d = floor(365.25 * y) + intg(30.6001 * (m + 1)) + day - 723244.0;
/**********************************************
** use Julian calendar if before Oct 5, 1582 **
**********************************************/
if (d < -145068.0) daynumb = d;
/*************************************
** otherwise use Gregorian calendar **
*************************************/
else
{
a = floor(y / 100.0);
b = 2 - a + floor(a / 4.0);
daynumb = d + b;
}
return(daynumb);
} /* end GETDAYS */
/********************************************************
* GETDATE - This routine takes a double float number *
* representing the number of days since Jan 1,*
* 1980 (day 1) and returns the year month and *
* day as pointer integers *
* This routine is the opposite of GETDAYS *
********************************************************/
getdate(numb)
double numb;
{
double a,aa,b,c,d,e,z;
double date;

date = numb;
z = intg(date + 2444239.0);
if (date < -145078.0) a = z;
else
{
aa = floor((z - 1867216.25) / 36524.25);
a = z + 1 + aa - floor(aa/4.0);
}
b = a + 1524.0;
c = intg((b - 122.1) / 365.25);
d = intg(365.25 * c);
e = intg((b - d) / 30.6001);
day = b - d - intg(30.6001 * e);
if (e > 13.5) month = e - 13.0;
else month = e - 1.0;
if (month > 2) year = c - 4716.0;
else year = c - 4715.0;
if (year < 1) --year;
return;
} /* end GETDATE */
/********************************************************
* WEEKDAYS - This routine takes a double float number *
* representing the number of days since Jan 1,*
* 1980 (day 1) and returns the day of the week*
* where 1 = Sunday, 2 = Tuesday, etc. *
********************************************************/
int weekdays(numb)
double numb;
{
double dd;
int day;

dd = numb;
while (dd > 28000.0) dd = dd - 28000.0;
while (dd < 0) dd = dd + 28000.0;
day = dd;
day = ((day + 1) % 7) + 1;
return(day);
}
/********************************************************
* FRACT - This routine takes a double float number *
* and returns the fractional part as a double *
* float number *
********************************************************/
double fract(numb)
double numb;
{
int inumb;
double fnumb;

while (numb < -32767) numb += 32767;
while (numb > 32767) numb -= 32767;
inumb = numb;
fnumb = inumb;
return(numb-fnumb);
} /* end FRACT */
/********************************************************
* FLOOR - This routine takes a double float number *
* and returns the next smallest integer *
********************************************************/
double floor(numb)
double numb;
{

double fract(), intg();
double out;
out = intg(numb);
if (numb < 0 && fract(numb) != 0) out -= 1.0;
return(out);
} /* end FLOOR */
/********************************************************
* INTG - This routine takes a double float number *
* and returns the integer part as a double *
* float number *
********************************************************/
double intg(numb)
double numb;
{
double fract();
return(numb - fract(numb));
} /* end INTG */

1.系统封面设计
内容:题目名称(中英文)、进入(中英文)、作者:***、时间:****-**-**
2.输入界面
内容:(1)密码口令输入及容错(3次)
(2)年份的输入及容错(3次)
3.日历计算设计
(1)求某月某日实行奇迹的函数(邱每月一号的星期数)。算法:(y-1)+(y-1)/4-(y-1)/100+(y-1)/400+c 得出S (y为年份,c为某月某日是这一年的第几天,S为总的天数)
(2)邱某月某日至这一年第几天的函数(求c) 闰年的算法: y/400==0 ?或y/400==0&&y/100!=0
根据(1)(2)求出每个月的日期
4、日历格式显示设计
要求:每屏显示4个月。
-------------------------------

求一篇,C语言时钟和万年历的程序设计论文。在线等,谢谢了
答:我的课程设计报告,希望对你有帮助!成绩 课程设计报告册 20 09 ~ 20 10 学年 第 2 学期 课程名称: C语言课程设计 任课教师:班 级: B090602 姓 名: 臧富跃 学 号: B09060243 20 10 年 6 月 一.课程设计题目:万年历 二.题目要求:(1) 程序...

用C语言设计一个年历系统 问题描述: 年历系统首先对于输入的任一年...
答:int i,j,n,m,num0=0,num1=31,nweek0=week,nweek1;if(year%4==0){ if(year%100!=0) month_day[2]=29;else { if(year%400==0) month_day[2]=29;else month_day[2]=28;} } else month_day[2]=28;system("CLS");printf("The calendar of the year %d\n\n",year);fo...

C语言年历显示程序设计
答:void month_print(int year,int month) //输入一个年月,输出这个月的日历{ int i,c,d; c=month_day(year,month); printf("\n\n %d年%d月日历\n",year,month); printf(" S M T W T F S \n"); d=j_week(year,month,1); for(i=1;i<=c+d;i++) { if(i<=d) printf(" "); ...

用C语言编写万年历系统
答:此系统拥有年历输出和日期的星期查询功能,要求操作界面友好... 此系统拥有年历输出和日期的星期查询功能,要求操作界面友好... 展开  我.../*显示日历函数*/void showCalendar(int year,int month,int day){ int i; int j; /*输出的日期*/ int outDay; int leapFlag; /*本月第一个...

c语言课程设计,关于年历显示。下面是要求: (1) 输入一个年份,输出是在...
答:monthday[1]++;} printf("*** %d ***\n",inputyear);for(i = 0;i<12;i++) //先一个月份一个月份的输出。{ printf("\n===\n");printf("%s\n",monthname[i]);for(j = 0;j<7;j++){ printf("%5s",weekname[j]);} for(j =0;j<monthday[i];j++){ if(j == ...

跪求C语言万年历程序设计
答: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_mday,(*timenow).tm_hour,(*timenow).tm_min);printf("\n\n本月...

如何用C语言编写一个万年历系统?
答:1.查询某年某月每一天对应星期几 2.可以查询某年某月的上个月或是下个月的日历情报 3.查询某年某月某日是这一年的第几天,并查询改天是星期几 4.判断该年是闰年还是平年,判断这一年的生肖 include <stdio.h> include <conio.h> include <dos.h> void rili(int,int);int runniansub(int)...

C语言课程设计,万年历算星期几,只要随便说出公元几几年几月几日就可以...
答:假如小于2000年,比如1991年,则对应的年份代码是(2000-1991)÷4=2……1,再用基数代码4加上2倍的商减去余数.即4+2×2-1=7,则1991年对应的年份代码为7.再记住1个特殊情况,即润年的3到12月份到最后要加1.1949年10月1日.则(2000-1949)÷4=12……3,再4+2×12-3=25,年份代码计算...

用C语言编写一份日历系统
答:定义一个数组 int c[12]={31,28,31,30,31,30,31,31,30,31,30,31} if(y%4==0&&y%100!=0&&y%400==0) //判断闰年的公式,我忘记了,呵呵 c[1]=29;else c[1]=28;这里用来存储每个月的天数。可以使全局数组,这样的话就是改变2月份的天数而已 要是打印一年的日历,不需要计算每个...

C语言程序设计万年历
答:{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...