本帖最後由 鐘彥博 於 2020-6-25 20:59 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re:
- system("cls");
- int a,b,mou;
- cout<<"[2020年月曆]"<<endl;
- cout<<endl;
- cout<<"請輸入想知道的月份(1~12):";
- cin>>mou;
- cout<<endl;
- switch(mou)
- {
- case 1:
- b=4;a=31;
- break;
- case 2:
- b=7;a=29;
- break;
- case 3:
- b=1;a=31;
- break;
- case 4:
- b=4;a=30;
- break;
- case 5:
- b=6;a=31;
- break;
- case 6:
- b=2;a=30;
- break;
- case 7:
- b=4;a=31;
- break;
- case 8:
- b=7;a=31;
- break;
- case 9:
- b=3;a=30;
- break;
- case 10:
- b=5;a=31;
- break;
- case 11:
- b=1;a=30;
- break;
- case 12:
- b=3;a=31;
- break;
- default:
- cout<<"Please try to read what I wrote on the screen!"<<endl;
- system("pause");
- goto re;
- }
- cout<<"日\t一\t二\t三\t四\t五\t六"<<endl;
- for(int j=1;j<=a+b-1;j++)
- {
- if(j<b)
- {
- cout<<" \t";
- }else
- {
- cout<<j-(b-1)<<" \t";
- }
- if(j%7==0)
- {
- cout<<endl;
- }
- }
- cout<<endl;
- cout<<endl;
- system("pause");
- goto re;
- system("pause");
- return 0;
- }
複製代碼 |