本帖最後由 李柏穎 於 2020-7-10 22:57 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re:
- system("cls");
- int days, start, month;
- cout<<"【 2020月曆查詢 】"<<endl<<endl;
- cout<<"請輸入要查詢的月份(1~12): ";
- cin>>month;
- switch(month)
- {
- case 1:
- days=31,start=4;
- break;
- case 2:
- days=29,start=7;
- break;
- case 3:
- days=31,start=1;
- break;
- case 4:
- days=30,start=4;
- break;
- case 5:
- days=31,start=6;
- break;
- case 6:
- days=30,start=2;
- break;
- case 7:
- days=31,start=4;
- break;
- case 8:
- days=31,start=7;
- break;
- case 9:
- days=30,start=3;
- break;
- case 10:
- days=31,start=5;
- break;
- case 11:
- days=30,start=1;
- break;
- case 12:
- days=31,start=3;
- break;
- default:
- cout<<"輸入錯誤,重新輸入"<<endl;
- system("pause");
- goto re;
- }
- cout<<endl<<"日\t一\t二\t三\t四\t五\t六"<<endl;
- for(int i=1; i<=days+(start-1); i++)
- {
- if(i<start)
- {
- cout<<" \t";
- }
- else
- {
- cout<<i-(start-1)<<" \t";
- }
- if(i/7==0)
- cout<<endl;
- }
- cout<<endl<<endl;
- system("pause");
- goto re;
- return 0;
- }
複製代碼 |