- UID
- 62936
注册时间2009-7-28
阅读权限8
最后登录1970-1-1
初入江湖
该用户从未签到
|
发表于 2009-8-28 22:34:16
|
显示全部楼层
我做的并没有认真去判断二月的天数,和没个月的天数。
第一题:
#include "stdafx.h"
#include <iostream.h>
#include <stdio.h>
#include <string.h>
int main()
{
int month,day,s;
cout<<"Input"<<endl;
cin>>month;
if (month<1||month>12)
{
cout<<"Wrong!Again.";
}
cin>>day;
if (month<1||month>31)
{
cout<<"Wrong!Again.";
}
s=(month*2+day)%3;
switch(s){
case 0:cout<<"普通"<<endl;break;
case 1:cout<<"吉"<<endl;break;
case 2:cout<<"大吉"<<endl;break;
default:break;
}
return 0;
}
第二题
#include "stdafx.h"
#include <iostream.h>
#include <stdio.h>
#include <string.h>
int main()
{
int year,month,day;
cout<<"Input:year-month-day!"<<endl;
cin>>year;
cin>>month;
cin>>day;
if ((year%4==0&&year%100!=0)||year%400==0)
{
cout<<"润年"<<endl;
}
else
cout<<"平年"<<endl;
return 0;
} |
|