CCF 201503-3 节日 100分
Posted 登登登ccc
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CCF 201503-3 节日 100分相关的知识,希望对你有一定的参考价值。
题目来源:- 计算机软件能力认证考试系统
#include<bits/stdc++.h>
using namespace std;
bool leap(int year) {
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
return true;
return false;
}
int main() {
int i;
int a, b, c, y1, y2, year, weekday, date = 2, ans_date;
int monDay[2][13] = { { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
{ 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
};
cin >> a >> b >> c >> y1 >> y2;
for (i = 1850; i < y1; i++)
if (leap(i))
date += 366;
else
date += 365;
for (year = y1; year <= y2; year++) {
for (i = 1; i < a; i++)
date += monDay[leap(year)][i];
weekday = date % 7;
c = c % 7;
if (weekday <= c)
ans_date = (b - 1) * 7 + (c - weekday + 1);
else
ans_date = (b - 1) * 7 + (c + 7 - weekday + 1);
if (ans_date <= monDay[leap(year)][a])
printf("%4d/%02d/%02d\\n", year, a, ans_date);
else
cout << "none"<<endl;
for (i = a; i <= 12; i++)
date += monDay[leap(year)][i];
}
return 0;
}
以上是关于CCF 201503-3 节日 100分的主要内容,如果未能解决你的问题,请参考以下文章