要求:输入任意一个日期的年、月、日的值,求出从公元1年1月1日到这一天总共有多少天,并求出这一天是星期几。
简单的循环结构,并结合基姆拉尔森公式,注意月份转换。
下面是源码,仅供参考:
#include <iostream>
using namespace std;
void month1(int i, int &count)
{
switch (i)
{
case 1:count += 31;break;
case 2:count += 29;break;
case 3:count += 31;break;
case 4:count += 30;break;
case 5:count += 31;break;
case 6:count += 30;break;
case 7:count += 31;break;
case 8:count += 31;break;
case 9:count += 30;break;
case 10:count += 31;break;
case 11:count += 30;break;
case 12:count += 31;break;