程序:
/*
Copyright (c) 2013, 烟台大学计算机学院
* All rights reserved.
* 作 者:赵玲玲
* 完成日期:2014 年 1 月 19 日
* 版 本 号:v1.0
* 输入描述: 无
* 问题描述:要求:基本功能必须具备(通过年月查询本月日历),另外要有一定的创新性,可自由发挥。
提示:
(1)以某年某月某日为星期几为条件,算输入的年月日的日历。
例如:1980年1月1日为星期二。
输入(2012/2),求输出该月的日历,首先需要计算2012年1月1日为星期几,来确定日历的格式(起止位置)。当输入日期有误时要重新输入。
(2)需要考虑闰年问题。
(3)格式控制的头文件为<iomanip> 格式为cout<<setw(6);
(4)可以在黑框框运行。
* 程序输出:
* 问题分析:
* 算法设计:略
*/
#include <iostream>
#include <iomanip>
//#include <>
using namespace std;
void days(long,int,int,int);
void output(long,int,int);
int main()
{
cout<<" **************"<<endl;
cout<<" *多功能万年历*"<<endl;
cout<<" **************"<<endl;
int y, m, d;
cout<<"输入年(1900年及以后) 月 日"<<endl;
cin>>y>>m>>d;
if(y<1900||m<1||m>12||d<1||d>31)//对输入做判断
{
cout<<"error!"<<endl;
}
int sum=d;//该年第几天
for(int i=1; i<m; i++)//对不同月份相加不同的天数
{
switch(i)
{
case 2:
sum+=(y%4=&