三天打鱼两天晒网
来源:互联网 发布:win10网络图标不能启用 编辑:程序博客网 时间:2024/05/17 05:01
#include <iostream>using namespace std;int days(int year,int month,int day);void main(){int year,month,day;int choose;cout<<"请输入年月日(用空格隔开):"<<endl;cin>>year>>month>>day;days(year,month,day); main();}int days(int year,int month,int day){int leap=0;int i,j,k=day, int sum=0;if(year<2010) //判断输入年份是否小于2010年{cout<<"输入年份错误"<<endl;return 0;}else{ for(int a=2010;a<=year;a++) //当年份大于2010年时,判断共度过了几个闰年{if(a%400==0||(a%4==0&&a%100!=0))leap++;}i=(year-2010)*365+leap;if(month>0&&month<13) //判断月份是否符合规定并将不同情况下每月的天数进行判定{if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){if(day>31){cout<<"输入日期错误"<<endl;return 0;}}else if(month==2){if(year%400==0||(year%4==0&&year%100!=0)){if(day>29){cout<<"输入日期错误"<<endl;return 0;}}elseif(day>28){cout<<"输入日期错误"<<endl;return 0;}}elseif(day>30){ cout<<"输入日期错误"<<endl;return 0;}switch(month) //根据月份输出天数{case 1:j=0;break;case 2:j=31;break;case 3:j=59;break;case 4:j=90;break;case 5:j=120;break;case 6:j=151;break;case 7:j=181;break;case 8:j=212;break;case 9:j=243;break;case 10:j=273;break;case 11:j=304;break;case 12:j=334;break;}sum=i+j+k; //从2010年1月1日开始到输入日期的总天数switch(sum%5){case 0:case 1:case 2:cout<<"在打鱼"<<endl;break; //当取余为0,1,2时是在打鱼case 3:case 4:cout<<"在晒网"<<endl;break; //当取余为3,4时是晒网}}elsecout<<"输入月份错误"<<endl;}}
0 0
- 三天打鱼两天晒网
- 三天打鱼两天晒网
- 三天打鱼两天晒网
- 三天打鱼,两天晒网
- 三天打鱼,两天晒网
- 三天打鱼两天晒网
- 三天打鱼,两天晒网
- 三天打鱼两天晒网
- 三天打鱼两天晒网
- 三天打鱼两天晒网
- 三天打鱼两天晒网
- 三天打鱼两天晒网
- 三天打鱼,两天晒网
- 三天打鱼两天晒网
- “三天打鱼两天晒网”
- 三天打鱼,两天晒网
- 三天打鱼两天晒网
- 三天打鱼两天晒网
- Apache Kafka
- 剑指Offer系列-面试题33:把数组排成最小的数
- linux常用命令20个
- 乐观锁、悲观锁、共享锁、排它锁
- 改写sort函数,使其执行按大到小排列
- 三天打鱼两天晒网
- 六.服务器硬件优化
- python hmmlearn 安装出错 Unable to find vcvarsall.bat
- hdu 2955(01背包问题)Robberies
- hive内部表与外部表区别详细介绍
- HTTP中Get与Post的区别
- 滑块: 基于Bootstrap的jQuery slider插件的使用bootstrap-slider.js
- win10系统 dshow 调用失效修复案例
- 透明Activity(Android)