万年历代码急求:万年历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...

friendhosting:(优惠55%)大促销,全场VPS降价55%,9个机房,不限流量

每年的7月的最后一个周五是全球性质的“系统管理员日”,据说是为了感谢系统管理员的辛苦工作....friendhosting决定从现在开始一直到9月8日对其全球9个数据中心的VPS进行4.5折(优惠55%)大促销。所有VPS基于KVM虚拟,给100M带宽,不限制流量,允许自定义上传ISO...官方网站:https://friendhosting.net比特币、信用卡、PayPal、支付宝、微信、we...

旅途云(¥48 / 月),雅安高防4核4G、洛阳BGP 2核2G

公司成立于2007年,是国内领先的互联网业务平台服务提供商。公司专注为用户提供低价高性能云计算产品,致力于云计算应用的易用性开发,并引导云计算在国内普及。目前,旅途云公司研发以及运营云服务基础设施服务平台(IaaS),面向全球客户提供基于云计算的IT解决方案与客户服务,拥有丰富的国内BGP、双线高防、香港等优质的IDC资源。点击进入:旅途云官方网商家LOGO优惠方案:CPU内存硬盘带宽/流量/防御...

万年历代码为你推荐
bft请问BFT高级是什么水平的?免费qq号有免费的QQ号和密码可以用的?apple以旧换新苹果手机可以以旧换新吗rbooracle中rbo和cbo的区别印度it为什么说在IT印度远远领先中国水平?spinmaster技术滑板截图方法协亨协亨,话机世界,迪信通哪个买手机更便宜?wifi快速破解器电脑版wifi万能钥匙电脑版怎么破解密码没有nvidia控制面板为什么我的电脑点击右键没有NVIDIA控制面板3d规则福彩3D具体玩法,包括规则,开奖时间等?
服务器租赁 ip反查域名 Oray域名注册服务商 双线vps 域名交易网 krypt 香港vps99idc mach 42u机柜尺寸 美国php主机 typecho 建站代码 777te 智能骨干网 架设服务器 135邮箱 双12 备案空间 阿里云官方网站 防cc攻击 更多