万年历程序设计c语言代码.doc_第1页
万年历程序设计c语言代码.doc_第2页
万年历程序设计c语言代码.doc_第3页
万年历程序设计c语言代码.doc_第4页
万年历程序设计c语言代码.doc_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

这是当时我做的一个小小的课题,希望对你有所帮助#include stdio.h /* Required for MS-DOS use */ #define ENTER 0x1C0D /* Enter key */ int year, month, day; static char *days8 = ,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 dateline47; /* date & time together */ ; static struct TIMEDATE today; main() char cmonth3; char cday3; char cyear5; double getdays(); double daynumb, numbnow; int weekday, retcode, dayer, i; dayer = datetime(&today); clrscn(); for (i=0;i3;+i)cmonthi=0; for (i=0;i3;+i)cdayi=0; for (i=0;i 0) printf(nn%02d-%02d-%d was,month, day, year); if (numbnow - daynumb 0) printf(nn%02d-%02d-%d will be,month, day, year); printf( a %sn,daysweekday); /* 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 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 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; 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

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论