我是靠谱客的博主 冷傲微笑,这篇文章主要介绍三天打鱼两天晒网问题,现在分享给大家,希望可以做个参考。

//打鱼晒网问题
#include<iostream>
using namespace std;
int number(int year, int month, int day);
int main()
{
int year, month, day, n;
cout << "Please enter the date:" << endl;
cin >> year;
cin >> month;
cin >> day;
cout << "The date is " << year << "/" << month << "/" << day << endl;
n = number(year, month, day);
if ((n % 5) <= 3 && (n % 5) > 0)
cout << "Fishing" << endl;
else
cout << "Basking" << endl;
return 0;
}
int leap(int a)
{
if (a % 4 == 0 && a % 100 != 0 || a % 400 == 0)
return 1;
else
return 0;
}
int number(int year, int month, int day)
{
int sum = 0, i, j, k;
int a[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int b[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if (leap(year==1))
for (i = 0; i < month; i++)
sum += b[i];
else
for (i = 0; i < month - 1; i++)
sum += a[i];
for (j = 2000; j < year;j++)
if (leap(year) == 1)
sum += 366;
else
sum += 365;
sum += day;
return sum;
}
比较综合的问题,有判断闰年问题,有计算日期的

最后

以上就是冷傲微笑最近收集整理的关于三天打鱼两天晒网问题的全部内容,更多相关三天打鱼两天晒网问题内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(60)

评论列表共有 0 条评论

立即
投稿
返回
顶部