万年历代码急求:万年历c代码 显示 属相 时间 日期 农历

万年历代码  时间:2021-08-03  阅读:()

c语言中编写万年历的代码要用到那些函数?

#include"stdio.h" #define YES 1 #define NO 0 int isleap(int year) { int leap=NO; if(year%4==0 && year%100!=0 || year%400==0) leap = YES; return leap; } int week_of_firstday(int year) { int n; n=(year+(year-1)/4-(year-1)/100+(year-1)/400)%7; return n; } int main() { int year,month,day,weekday,len_of_month,i; printf("请输入年份:"); scanf("%d",&year); weekday=week_of_firstday(year); for(month=1;month<=12;month++) { printf(" "); printf(" %d年%d月 ",year,month); printf("--------------------- "); printf("日 一 二 三 四 五 六 "); printf("--------------------- "); for(i=0;i<weekday;i=i+1) printf(" "); if(month==4||month==6||month==9||month==11) len_of_month=30; else if(month==2) { if(isleap(year)) len_of_month=29; else len_of_month=28; } else len_of_month=31; for(day=1;day<=len_of_month;day++) { if(day>9) printf("%d ",day); else printf("%d ",day); weekday++; if(weekday==7) { weekday=0; printf(" "); } } printf(" "); } return 0; }

求万年历代码 一定要C++的 最好全面点

一个万年历的C++实现代码 #include < iostream > #include < iomanip > using namespace std; int FistDayofYear( int y); int DaysofMonth( int m); void PrintMonth( int m); void PrintHead( int m); bool LeapYear( int y); int WeekDay,year; void main() { INPUT: cerr << " 请输入年份(>1): " ; cin >> year; WeekDay = FistDayofYear(year); cout << " " << year << " 年 " ; cout << " ========================================================== " ; for ( int a = 1 ;a < 13 ;a ++ ) PrintMonth(a); cout << endl; int r = 0 ,u = 0 ; cout << " 继续打1,退出打0 : " ; cin >> r; if (r > u) goto INPUT; else goto END; END:; } void PrintMonth( int m) { PrintHead(m); int day = DaysofMonth(m); for ( int i = 1 ;i <= day;i ++ ) { cout << setw( 5 ) << i; WeekDay = (WeekDay + 1 ) % 7 ; if (WeekDay == 0 ) { cout << endl; cout << setw( 5 ) << " " ; } } } void PrintHead( int m) { cout << " " << setw( 5 ) << m; cout << " 月 日 一 二 三 四 五 六 " ; cout << setw( 5 ) << " " ; for ( int i = 0 ;i < WeekDay;i ++ ) cout << setw( 5 ) << " " ; } int DaysofMonth( int m) { switch (m) { case 1 : case 3 : case 5 : case 7 : case 8 : case 10 : case 12 : return 31 ; case 4 : case 6 : case 9 : case 11 : return 30 ; case 2 : if (LeapYear(year)) return 29 ; else return 28 ; } return 0 ; } bool LeapYear( int y) { return (y % 4 == 0 && y % 100 != 0 || y % 400 == 0 ); } int FistDayofYear( int y) { long m; m = y * 365 ; for ( int i = 1 ;i < y;i ++ ) m += LeapYear(i); return m %= 7 ; }

急求:万年历c代码 显示 属相 时间 日期 农历

/* * 程序名称: 万年历 * 功能描述: 在字符界面下显示万年历的功能. * 设计编程: 董小向 * 时 间: 2007-5 */ #include <stdio.h> #include <time.h> #include <stdlib.h> #include <conio.h> #include <ctype.h> #define CURU 72 #define CURD 80 #define CURL 75 #define CURR 77 #define ESC 27 void printWNL(int, int); //简单格式打印万年历 void printWNL2(int, int); //打印带表格的万年历 int Week(int,int,int); //求星期几 int getDays(int, int); //计算某个月的天数 int isRunNian(int); //判断是否闰年 /* *主函数,应用程序入口 */ void main() { int year,month; struct tm t; char ch; _getsystime(&t); //标准函数, 获得系统当前时间 year = t.tm_year + 1900; //得到当前年份 month = t.tm_mon + 1; //得到当前月份 do { system("cls"); //调用DOS清屏命令 printWNL(year,month); //自定义函数, 打印万年历 ch = getch(); //获得无回显控制台输入字符 if(ch == ESC) //ESC键,退出循环,结束程序 break; else if(ch == 0) //若值为零,则用户敲了功能键,继续获取后续代码。

ch = getch(); switch(ch) { case CURL: year--; break; //左键减年 case CURR: year++; break; //右键加年 case CURU: //上键减月 month--; if(month == 0) { month = 12; year--; } break; case CURD: //下键加月 month++; if(month == 13) { month = 1; year++; } break; default:; } }while(1); printf(" 谢谢使用,欢迎常来!再见。

"); } /* *简单格式打印万年历 *参数: y 整型,接收年份值; m 整型,接收月份值; *返回值: 无 */ void printWNL(int y, int m) { int i,j; int day = 1 - Week(y,m,1); //天数初始值,定位1号的位置 int days = getDays(y,m); printf(" %4d年%2d月 ",y,m); printf(" 日 一 二 三 四 五 六 "); for(i = 1; i <= 6; i++) { for(j = 1; j <= 7; j++) { if(day <= 0 || day > days) printf(" "); else printf("%3d",day); day++; } printf(" "); } printf(" 提示:【←】减年 【→】加年 【↑】减月 【↓】加月 【ESC】退出 "); } /* *求星期几 *参数: y 整型,接收年份值; m 整型,接收月份值; d 整型,接收天的号数 *返回值: 整型, 是0,1-6七个数之间的一个数,0代表星期日,1-6代表星期一至星期六 */ int Week(int y,int m,int d) { int days = 0; //总天数 int i; for(i = 1; i < y; i++) //累计1到y-1年的天数 days += isRunNian(i) ? 366 : 365; for(i = 1; i < m; i++) //累计y年第1月到第m-1月的天数 days += getDays(y,i); days += d; //累计当月的天数。

return days % 7; //返回星期值 } /* *判断是否闰年 *参数: y 整型, 接收年份值 *返回值: 整型, 只为0或1, 0代表假, 1代表真 */ int isRunNian(int y) { return (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) ? 1 : 0; } /* *计算某个月的天数 *参数: y 整型,接收年份值; m 整型,接收月份值; *返回值: 整型, 是0, 28, 29, 30, 31之间的一个数 *注意: 返回值为0,表示你调用该函数时传递了不正确的年份值或月份值. */ int getDays(int y, int m) { int days = 0; switch(m) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: days = 31; break; case 4: case 6: case 9: case 11: days = 30; break; case 2: days = isRunNian(y) ? 29 : 28; break; default:; } return days; } void printWNL2(int y, int m) { int i,j; int day = 1 - Week(y,m,1); //天数初始值,定位1号的位置 int days = getDays(y,m); printf(" ╔══════════════════════════╗"); printf(" ╔══万年历 查询═════════════════╗║ "); printf(" ║ %4d 年 %2d 月 ║║ ",y,m); printf(" ╟———┬———┬———┬———┬———┬———┬———╢║ "); printf(" ║ 日 │ 一 │ 二 │ 三 │ 四 │ 五 │ 六 ║║ "); for(i = 1; i <= 6; i++) { printf(" ╟———┼———┼———┼———┼———┼———┼———╢║ "); printf(" ║"); for(j = 1; j <= 7; j++) { if(day <= 0 || day > days) printf(" "); else printf(" %2d ",day); j < 7 ? printf("│") : i < 6 ? printf("║║") : printf("║╝"); day++; } printf(" "); } printf(" ╚═══╧═══╧═══╧═══╧═══╧═══╧═══╝ "); printf(" 提示:【←】减年 【→】加年 【↑】减月 【↓】加月 【ESC】退出 "); }

捷锐数据399/年、60元/季 ,香港CN2云服务器 4H4G10M

捷锐数据官网商家介绍捷锐数据怎么样?捷锐数据好不好?捷锐数据是成立于2018年一家国人IDC商家,早期其主营虚拟主机CDN,现在主要有香港云服、国内物理机、腾讯轻量云代理、阿里轻量云代理,自营香港为CN2+BGP线路,采用KVM虚拟化而且单IP提供10G流量清洗并且免费配备天机盾可达到屏蔽UDP以及无视CC效果。这次捷锐数据给大家带来的活动是香港云促销,总共放量40台点击进入捷锐数据官网优惠活动内...

快云科技:夏季大促销,香港VPS7.5折特惠,CN2 GIA线路; 年付仅不到五折巨惠,续费永久同价

快云科技怎么样?快云科技是一家成立于2020年的新起国内主机商,资质齐全 持有IDC ICP ISP等正规商家。我们秉承着服务于客户服务于大众的理念运营,机器线路优价格低。目前已注册用户达到5000+!主营产品有:香港弹性云服务器,美国vps和日本vps,香港物理机,国内高防物理机以及美国日本高防物理机!产品特色:全配置均20M带宽,架构采用KVM虚拟化技术,全盘SSD硬盘,RAID10阵列, 国...

Pacificrack:新增三款超级秒杀套餐/洛杉矶QN机房/1Gbps月流量1TB/年付仅7美刀

PacificRack最近促销上瘾了,活动频繁,接二连三的追加便宜VPS秒杀,PacificRack在 7月中下旬已经推出了五款秒杀VPS套餐,现在商家又新增了三款更便宜的特价套餐,年付低至7.2美元,这已经是本月第三波促销,带宽都是1Gbps。PacificRack 7月秒杀VPS整个系列都是PR-M,也就是魔方的后台管理。2G内存起步的支持Windows 7、10、Server 2003\20...

万年历代码为你推荐
微指数微指数的新浪微博官方应用-微指数php开发工具php开发工具有哪些系统登录界面谁知道XP系统的登录界面。和启动界面怎么更改的 急蓝牙开发蓝牙技术到底是指什么?微信收费微信平台是否要收费如何收费廖华《学学孔子怎样当老师》读后感 南京廖华文件系统格式系统盘是什么格式网页错误详细信息网页错误详细信息 消息: 'this._self.style' 为空或不是对象移动硬盘提示格式化我要打开可移动磁盘 为什么显示格式化snoopy官网SNOOPY护肤品究竟是国内生产的吗?在哪生产的?
免费国际域名 万网域名证书查询 仿牌空间 dreamhost la域名 英文简历模板word 美国在线代理服务器 上海电信测速网站 vul 江苏徐州移动 广州主机托管 mteam 密钥索引 腾讯云平台 酷锐 美国主机 侦探online 德国代理ip neicun 回程 更多