当前位置:编程学习 > C/C++ >>

求一个课程设计(C++编程的)

用VC6.0编写一个万年历,用C++语言写的。要求发原代码给我,要能运行的。邮箱358472539@qq.com
补充:编写一万年历系统

 要求:  模仿现实生活中的挂历. 

当前页以系统当前日期的月份为准显示当前月的每一天(显示出日及对应的星期几).

当系统日期变到下一月时,系统自动翻页到下一月.

追问:非常感谢 程序可以运行 没有错误
答案:直接复制给你吧,虽然不是自己写的。嘿嘿。

#include<iostream.h>
#include<iomanip.h>
int fn1(int year,int month,int day);
int monthday(int year,int month);
void fn2(int year,int month);
void fn3(int year);
void main()
{
int year,month,day,i,x;
cout<<endl<<endl;
cout<<"                --------------------------------------"<<endl;
cout<<"                *                                    *"<<endl;
cout<<"                      欢迎进入万年历查询系统          "<<endl;
cout<<"                *                                    *"<<endl;
cout<<"                --------------------------------------"<<endl;
cout<<endl<<endl;
cout<<"                程序员: "<<endl<<endl;
cout<<"                河南理工大学"<<endl;
loop:cout<<endl<<endl;
cout<<"               请您选择查询内容;"<<endl<<endl;
cout<<"                1.显示一年的日历:"<<endl;
cout<<"                2.显示一个月的日历:"<<endl;
cout<<"                3.显示某一天是周几:"<<endl;
cout<<"                0.退出:"<<endl;
cout<<endl;
cout<<"请输入(0-3)中的数字选择您要查询的内容"<<endl;
cin>>i;
switch(i)
{
case 0: return;
case 1:
{
cout<<"请输入年份,输入格式为****"<<endl;
cin>>year;
fn3(year);
}break;

case 2:
{
cout<<"请输入您要查询的日期,输入格式为**** **"<<endl<<"如2009 11"<<endl;
cin>>year>>month;
fn2(year,month);
}break;
case 3:
{
cout<<"请输入您要查询的日期,输入格式为**** ** **"<<endl<<"如2009 11 23"<<endl;
cin>>year>>month>>day;
cout<<year<<"年"<<month<<"月"<<day<<"日"<<"是星期"<<fn1(year,month,day)<<endl;
}break;
default:cout<<"输入错误"<<endl;
}
cout<<"继续查询请输 1 "<<endl<<"退出查询请输 0"<<endl;
cin>>x;
if(x==1)
goto loop;
}
int fn1(int year,int month,int day)
{

int yearjs,monthjs,monthday=0;
int permonthday[12]={31,28,31,30,31,30,31,31,30,31,30,31};
for(int i=0;i<month-1;i++)
monthday=monthday+permonthday[i];
if(year%4==0&&year%100==0||year%400==0)
{
yearjs=2;
if(month>2)
monthjs=(monthday+1)%7;
else
monthjs=monthday%7;

}
else
{
yearjs=1;
monthjs=monthday%7;
}

return ((year+year/4+year/400-year/100-yearjs+monthjs+day)%7)==0?7:((year+year/4+year/400-year/100-yearjs+monthjs+day)%7);
}

int monthday(int year,int month)
{

int permonthday[12]={31,28,31,30,31,30,31,31,30,31,30,31};
if(month!=2)
return permonthday[month-1];
else
{
if(year%4==0&&year%100==0||year%400==0)
return 29;
else
return 28;
}
}

void fn2(int year,int month)
{
cout<<endl<<endl;
cout<<setw(6)<<"一"<<setw(6)<<"二"<<setw(6)<<"三"<<setw(6)<<"四"<<setw(6)<<"五"<<setw(6)<<"六"<<setw(6)<<"日"<<endl;
for(int i=1;i<=monthday(year,month);i++)
{
if(i==1)
{
for(int j=1;j<fn1(year,month,1);j++)
{
cout.width(6);
cout<<setw(6)<<" ";
}
cout<<setw(6)<<i;
}
else
{
if((i+fn1(year,month,1)-2)%7==0)
cout<<endl;
cout<<setw(6)<<i;
}
}
cout<<endl<<endl;
}
void fn3(int year)
{
for(int i=1;i<=12;i++)
{
cout<<i<<" 月"<<endl;
fn2(year,i);
cout<<endl<<endl;
}
}

上一个:C++中重载流运算符的疑问
下一个:c++程序设计英文打字练习程序

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,