日期转换周期(续)

//程序目的给出年月日,显示对应的星期。
#include<iostream>
using namespace std;
const char _char='-';
//const char Y='/';
void genl_(int month,int day,int year)
{
 int temp(0),i(0),ave,k=0;//temp记录总共闰年数,ave除7余数,k当年元旦到上月总天数
 long sumday(0);//始元至今总天数
 if(month==2)
 {
  if(year%4==0&&year%100!=0||year%400==0)
  {
   if(day>29)
   {
    cout<<"I have no patience to fuck you."<<endl;
    return ;
   }
  }
  else
  {
   if(day>28)
   {
    cout<<"I have no patience to fuck you twice."<<endl;
    return;
   }
  }
 }
 if(year<0||month>12||month<1||day>31||day<1)
 {
  cout<<"Stupid eggs,You do know how many months one year or days one month."<<endl;
 }
 else if((month==4||month==6||month==9||month==11)&&day>30)
 {
  cout<<"Stupid eggs,You do know how many months one year or days one month,fuck you.I cannot understand."<<endl;
 }
 else
 {
  for(;i<year;i++)
  {
   if(i%4==0&&i%100!=0||i%400==0)
    temp++;
  }
  if(year>1)
   sumday=(year-1)*365+temp;//year-1年的总天数
  else
   sumday=temp;
  switch(month)
  {
  case 1:k=0;break;
  case 2:k=31;break;
  case 3:k=59;break;
  case 4:k=90;break;
  case 5:k=120;break;
  case 6:k=151;break;
  case 7:k=181;break;
  case 8:k=212;break;
  case 9:k=243;break;
  case 10:k=273;break;
  case 11:k=304;break;
  case 12:k=334;break;
  }
  sumday=sumday+k+day;
  if((year%4==0&&year%100!=0||year%400==0)&&month>2)
   sumday+=1;
  ave=sumday%7;
  switch(ave)
  {
  case 0:cout<<month<<_char<<day<<_char<<year<<" is Saturday.";break;
  case 1:cout<<month<<_char<<day<<_char<<year<<" is Sunday.";break;
  case 2:cout<<month<<_char<<day<<_char<<year<<" is Monday.";break;
  case 3:cout<<month<<_char<<day<<_char<<year<<" is Tuesday.";break;
  case 4:cout<<month<<_char<<day<<_char<<year<<" is Wednesday.";break;
  case 5:cout<<month<<_char<<day<<_char<<year<<" is Thursday.";break;
  case 6:cout<<month<<_char<<day<<_char<<year<<" is Friday.";break;
  }
  cout<<endl;
 }
}
int main(void)
{
 cout<<"Please input the data you want.Presentation(格式) is month space day space year!(the space means that you should input a space behind you have done but year.)"<<endl;
 cout<<"作者:  四川大学计算机学院2008级 计算机科学与技术 贾钰"<<endl;
 cout<<endl;
 cout<<"*********每天睡前、起后大喊三声“钰哥好!”精神抖擞一天。***********"<<endl;
 cout<<endl;
 cout<<"输入格式示例。比如:2009年9月2日"<<endl;
 cout<<"input: 9 2 2009"<<endl;
 cout<<"output: 2009-9-2 is Wednesday."<<endl;
 cout<<"请输入你想查询的日期(Please input the data you want.):"<<endl;
 int d,m,y;
 while(cin>>m>>d>>y)
  genl_(m,d,y);
 return 0;
}

你可能感兴趣的:(网络,职场,休闲)