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

3元/首月香港便宜vps究竟是什么货。

便宜的香港vps多少钱?现在国外VPS主机的价格已经很便宜了,美国VPS主机最低一个月只要十几元,但同样免备案的香港VPS价格贵不贵呢?或者说便宜的香港VPS多少钱?香港vps主机价格要比美国机房的贵一些,但比国内的又便宜不少,所以目前情况是同等配置下,美国VPS比香港的便宜,香港VPS比国内(指大陆地区)的便宜。目前,最便宜香港vps低至3元/首月、18元/月起,今天云服务器网(www.yunt...

什么是BGP国际线路及BGP线路有哪些优势

我们在选择虚拟主机和云服务器的时候,是不是经常有看到有的线路是BGP线路,比如前几天有看到服务商有国际BGP线路和国内BGP线路。这个BGP线路和其他服务线路有什么不同呢?所谓的BGP线路机房,就是在不同的运营商之间通过技术手段时间各个网络的兼容速度最佳,但是IP地址还是一个。正常情况下,我们看到的某个服务商提供的IP地址,在电信和联通移动速度是不同的,有的电信速度不错,有的是移动速度好。但是如果...

JustHost,最新高性价比超便宜俄罗斯CN2 VPS云服务器终身8折优惠,最低仅8元/月起,200Mbps带宽不限流量,五大机房自助自由切换,免费更换IP,俄罗斯cn2vps怎么样,justhost云服务器速度及综合性能详细测评报告

主机参考最新消息:JustHost怎么样?JustHost服务器好不好?JustHost好不好?JustHost是一家成立于2006年的俄罗斯服务器提供商,支持支付宝付款,服务器价格便宜,200Mbps大带宽不限流量,支持免费更换5次IP,支持控制面板自由切换机房,目前JustHost有俄罗斯5个机房可以自由切换选择,最重要的还是价格真的特别便宜,最低只需要87卢布/月,约8.5元/月起!just...

万年历代码为你推荐
安全防护谈谈你对自我安全防护的看法,如何保障自身安全和企业安全?cs躲猫猫cs躲猫猫的游戏叫什么spinmaster技术滑板截图方法空间图片qq空间图片文件系统格式系统盘用什么格式好没有nvidia控制面板为什么我的电脑点击右键没有NVIDIA控制面板移动硬盘提示格式化移动硬盘显示需要格式化怎么修复平均数计算器卡西欧计算器怎样求平均数微信备份通讯录在哪微信6.3.6通讯录备份在哪从零开始学android从零开始学android需要多久
四川虚拟主机 到期域名查询 域名交易网 lamp安装 服务器配置技术网 t牌 万网优惠券 panel1 网站挂马检测工具 河南服务器 admit的用法 赞助 泉州电信 域名与空间 游戏服务器出租 lamp的音标 创速 卡巴斯基官网下载 北京主机托管 上海联通 更多