万年历代码急求:万年历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】退出 "); }

Cloudxtiny:£1.5/月,KVM-512MB/100GB/英国机房

Cloudxtiny是一家来自英国的主机商,提供VPS和独立服务器租用,在英国肯特自营数据中心,自己的硬件和网络(AS207059)。商家VPS主机基于KVM架构,开设在英国肯特机房,为了庆祝2021年欧洲杯决赛英格兰对意大利,商家为全场VPS主机提供50%的折扣直到7月31日,优惠后最低套餐每月1.5英镑起。我们对这场比赛有点偏见,但希望这是一场史诗般的决赛!下面列出几款主机套餐配置信息。CPU...

VirMach:$27.3/月-E3-1240v1/16GB/1TB/10TB/洛杉矶等多机房

上次部落分享过VirMach提供的End of Life Plans系列的VPS主机,最近他们又发布了DEDICATED MIGRATION SPECIALS产品,并提供6.5-7.5折优惠码,优惠后最低每月27.3美元起。同样的这些机器现在订购,将在2021年9月30日至2022年4月30日之间迁移,目前这些等待迁移机器可以在洛杉矶、达拉斯、亚特兰大、纽约、芝加哥等5个地区机房开设,未来迁移的时...

CheapWindowsVPS:7个机房可选全场5折,1Gbps不限流量每月4.5美元

CheapWindowsVPS是一家成立于2007年的老牌国外主机商,顾名思义,一个提供便宜的Windows系统VPS主机(同样也支持安装Linux系列的哈)的商家,可选数据中心包括美国洛杉矶、达拉斯、芝加哥、纽约、英国伦敦、法国、新加坡等等,目前商家针对VPS主机推出5折优惠码,优惠后最低4GB内存套餐月付仅4.5美元。下面列出几款VPS主机配置信息。CPU:2cores内存:4GB硬盘:60G...

万年历代码为你推荐
波浪号word里波浪号怎么打可以访问违规网站的浏览器360浏览器能设置禁止访问某些网页吗。。excel通配符EXCEL中通配符trapezoid梯形中最多有多少个直角?初始化磁盘win7系统如何磁盘初始化?逗号运算符逗号运算符详解aftereffectafter effect (AE)有哪几层,层有哪些属性?作用是什么?密码设置开机密码怎么设定?微店是什么开微店和开淘宝店有什么区别吗充值卡充值移动手机充值卡如何充值?
传奇服务器租用 申请个人网页 京东商城双十一活动 骨干网络 什么是刀片服务器 电信主机 带宽租赁 贵阳电信测速 深圳域名 万网注册 godaddy空间 杭州电信 七牛云存储 服务器托管价格 密钥索引 googlevoice japanese50m咸熟 腾讯服务器 六维空间登陆首页 关闭空间申请 更多