农历

wangjian1987 2008-06-09 03:52:54
请告诉一下农历是怎样定义的
尽量详细点
...全文
92 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangjian1987 2008-06-10
  • 打赏
  • 举报
回复
谢谢
wangjian1987 2008-06-10
  • 打赏
  • 举报
回复
我喜欢刘德华
program2050 2008-06-09
  • 打赏
  • 举报
回复
我也想知道。
Learn-anything 2008-06-09
  • 打赏
  • 举报
回复
不知道,帮顶
wangjian1987 2008-06-09
  • 打赏
  • 举报
回复
谢谢你的回复啊,不过我是要它的定义而不是算法啊
wangjian1987 2008-06-09
  • 打赏
  • 举报
回复
我baidu google了,就是找不到啊,只有些程序源代码
qiucp 2008-06-09
  • 打赏
  • 举报
回复
楼主baidu,google啊
longjing_g 2008-06-09
  • 打赏
  • 举报
回复
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<iomanip>
using namespace std;


bool leap(int);
int week(int);
void output(int);

int main(int argc, char* argv[])
{
int year;

cout<<"Please Input the year:"<<endl;

cin>>year;

output(year);

cout<<"Do you want to continue?(y or n):"<<endl;
char ch;
cin>>ch;
while (ch=='y')
{
cout<<"please input the year:"<<endl;
cin>>year;
output(year);
cout<<"Do you want to continue?(y or n):"<<endl;
cin>>ch;
}

return 0;
}

void output(int year)
{
string mon[12]={"January","February","March","April","May","June",
"July","August","September","October","November","December"};
int max_date[12]={31,0,31,30,31,30,31,31,30,31,30,31};

int i=week(year);

for(int j=0;j<12;j++)
{
if(leap(year))
max_date[1]=29;
else
max_date[1]=28;
cout<<'*'<<mon[j]<<'*'<<endl;
cout<<" Sun Mon Tue Wed Thu Fri Sat"<<endl;
for(int k=0;k<2+5*i;k++)
cout<<' ';
for(int d=1;d<=max_date[j];d++)
{
cout<<d<<setw(5);

if(i==6)
{
cout<<'\n';
if(d<9)
cout<<" ";
else
cout<<' ';
}
i=(i+1)%7;

}
cout<<endl;
}
}

bool leap(int year)
{
if(!(year>=0))
{
cerr<<"Input Error!"<<endl;
exit(1);
}
else if(year%4==0&&year%100!=0||year%400==0)
return true;
else
return false;
}
//2004.9.20.monday
int week(int year)
{
int i,k,j;
i=abs(2004-year);

k=(int)abs((abs(2004-year))/4);

j=365*(i-k)+k*366+263;

j=j%7;

if(year>2004)
return (j+1)%7;
else
{
if(j==4)
return 4;

else if(j==0)
return 1;
else if(j==1)
return 0;
else
{
if(j>4)
return j-2*(j-4);
else
return j+2*(4-j);
}

}
}

69,336

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧