锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
#include <iostream.h>
#include <iomanip.h>
int year;
int weekday;
//---------------------------------------
void PrintMonth(int m);//鎵撳嵃姣忎釜鏈?/font>
void PrintHead(int m);//鎵撳嵃鏈堟爣棰?/font>
int DaysOfMonth(int m);//璁$畻姣忎釜鏈堝ぉ鏁?/font>
bool IsLeapYear(int m);//闂板勾鍒ゆ柇
long WeekdayOfYear(int y);//鏌愬勾鐨勭涓澶?/font>
//---------------------------------------
int main()
{
聽//鎵撳嵃騫村巻澶?/font>
聽cout << "please enter the year:";
聽cin >> year;
聽if (year<1)
聽聽cout << "杈撳叆鐨勫勾涓嶈兘灝忎簬1!"<<endl;
聽cout <<"錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛?<<endl;
聽cout << "聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 "<<year<<"騫綽犅犅犅犅犅犅犅犅犅犅犅犅犅?"<<endl;
聽cout <<"錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛濓紳錛?<<endl;
聽//姹傚紑澶寸涓澶╂槦鏈熷嚑
聽weekday=WeekdayOfYear(year);
聽//鎵撳嵃姣忎釜鏈?/font>
聽for (int i=1;i<=12;i++)
聽聽PrintMonth(i);
聽
聽return (0);
}
//-----------------------------------------
void PrintMonth(int m)
{
聽//鎵撳嵃鏈堟爣棰?/font>
聽PrintHead(m);
聽//璁$畻姣忎釜鏈堝ぉ鏁?/font>
聽int days=DaysOfMonth(m);
聽//鎵撳嵃鏃ユ湡
聽for (int i=1;i<=days;i++)
聽{
聽聽cout << setw(5)<<i;
聽聽weekday=(weekday+1)%7;
聽聽if (weekday%7==0)
聽聽{
聽聽聽cout << endl;
聽聽聽cout << "聽聽聽聽聽聽聽聽聽 ";
聽聽}
聽}
聽cout <<endl;
}
//-------------------------------------------
void PrintHead(int m)
{
聽cout << setw(3)<<m<<"鏈?<<"聽聽聽聽聽聽聽聽鏃ヂ犅犅犱竴聽聽聽浜屄犅犅犱笁聽聽鍥浡犅犅犱簲聽聽 鍏?<<endl;
聽cout <<"聽聽聽聽聽聽聽聽聽 ";
聽for (int i=0;i<weekday;i++)
聽聽cout << "聽聽聽聽 ";
}
//--------------------------------------------
int DaysOfMonth(int m)
{
聽switch (m)
聽{
聽case 1:
聽case 3:
聽case 5:
聽case 7:
聽case 8:
聽case 10:
聽case 12: return(31);break;
聽case 4:
聽case 6:
聽case 9:
聽case 11: return(30);break;
聽default:
聽聽if(IsLeapYear(year))
聽聽聽return(29);
聽聽else
聽聽聽return(28);
聽}
}
//---------------------------------------------
bool IsLeapYear(int y)
{
聽return (((y%4==0)&&(y%100!=0))||(y%400==0));
}
//----------------------------------------------
long WeekdayOfYear(int y)
{
聽long TotalDay=0;
聽//姹傛誨ぉ鏁?/font>
聽for (int i=1;i<=y;i++)
聽聽TotalDay+=365;
聽//鍔犱笂闂板勾澶╂暟
聽for (int j=0;j<=y;j++)
聽聽TotalDay+=IsLeapYear(y);
聽TotalDay%=7;
聽return(TotalDay);
}
int main()
{
聽struct jose *head,*p_curent,*p_find;
聽int n,m;
聽cout << "Please enter the total of numbers (n):";
聽cin >> n;
聽cout << "Please enter the counter number (m):";
聽cin >> m;
聽
聽//鍒濆鍖栭摼琛?/span>
聽head=p_curent=new jose;//鏍囪棣栬〃鍏冨湴鍧錛屽嵆澶存寚閽?/span>
聽head->no=1;
聽cout << "Please enter the first number :";
聽cin >>head->data;
聽//褰㈡垚鍏朵綑鐨刵-1琛ㄥ厓
聽cout << "Please enter last numbers :"<<endl;
聽for (int i=2;i<=n;i++)
聽{
聽聽p_curent->next=new jose;
聽聽p_curent=p_curent->next;
聽聽cin >> p_curent->data;
聽聽p_curent->no=i;
聽}//end for
聽p_curent->next=head;//灝炬寚閽堟寚鍚戝ご鎸囬拡錛屽艦鎴愮幆錛屽埌榪欏畬鎴愬垵濮嬪寲閾捐〃
聽//寮濮嬫煡璇紝絎琈涓漢鍑哄垪錛屽茍杈撳嚭
聽cout << "Now : The聽 numbers of who will quit the cycle in turn are:"<<endl;
聽while (n)//鍏ㄩ儴鍑哄垪鍚庣粨鏉熷驚鐜?br />聽{
聽聽//鎺犺繃m錛?涓〃鍏?br />聽聽for (int j=1;j<m;j++)
聽聽聽p_curent=p_curent->next;//end聽for
聽聽//鎵懼埌絎琈涓漢
聽聽p_find=p_curent->next;
聽聽//浠庤〃涓垹闄ょm涓漢錛屽茍杈撳嚭絎琺涓漢
聽聽p_curent->next=p_find->next;
聽聽cout << p_find->data<<endl;
聽聽//閲婃斁絎琺涓〃鍏冨崰鐢ㄧ殑絀洪棿
聽聽delete p_find;
聽聽n--;
聽}
聽//end while
聽
聽return 0;
}