1.3 打渔还是晒网
#include <iostream> using namespace std; class Date { public: int year; int month; int day; }; bool runnian(Date&d) { if ((d.year % 4 == 0 && d.year % 100 != 0) || d.year % 400 == 0) { return true; } else { return false; } } bool runnian(int x) { if ((x % 4 == 0 && x % 100 != 0) || x % 400 == 0) { return true; } else { return false; } } int main() { Date d1; int a[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; int count = 0; //用来保存相隔的天数 cin >> d1.year; cin >> d1.month; cin >> d1.day; for (int i = 1990; i < d1.year; i++) { if (runnian(i)) { count = count + 366; } else { count = count + 365; } } for (int i = 0; i < d1.month; i++) { count = count + a[i]; } count = count + d1.day; if (count % 5 == 1 || count % 5 == 2 || count % 5 == 3) { cout << "今天打鱼" << endl; } else { cout << "今天晒网" << endl; } return 0; }