- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re:
- system("cls");
- int x,y,z;
- cout<<"[2020年月曆]"<<endl;
- cout<<endl;
- cout<<"請輸入想知道的月份(1~12):";
- cin>>z;
- cout<<endl;
- switch(z)
- {
- case 1:
- y=4;x=31;
- break;
- case 2:
- y=7;x=29;
- break;
- case 3:
- y=1;x=31;
- break;
- case 4:
- y=4;x=30;
- break;
- case 5:
- y=6;x=31;
- break;
- case 6:
- y=2;x=30;
- break;
- case 7:
- y=4;x=31;
- break;
- case 8:
- y=7;x=31;
- break;
- case 9:
- y=3;x=30;
- break;
- case 10:
- y=5;x=31;
- break;
- case 11:
- y=1;x=30;
- break;
- case 12:
- y=3;x=31;
- break;
- default:
- cout<<"請嘗試閱讀我在屏幕上寫的內容!"<<endl;
- system("pause");
- goto re;
- }
- cout<<"日\t一\t二\t三\t四\t五\t六"<<endl;
- for(int j=1;j<=x+y-1;j++)
- {
- if(j<y)
- {
- cout<<" \t";
- }else
- {
- cout<<j-(y-1)<<" \t";
- }
- if(j%7==0)
- {
- cout<<endl;
- }
- }
- cout<<endl;
- cout<<endl;
- system("pause");
- goto re;
- system("pause");
- return 0;
- }
複製代碼 |