- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int i,j,k;
- cout<<"[ 2020年月利查詢 ]"<<endl<<endl;
- cout<<"請輸入欲查詢的月份:";
- cin>>k;
- cout<<endl;
- switch(k)
- {
- case 1:
- case 3:
- case 5:
- case 7:
- case 8:
- case 10:
- case 12:
- i=31;
- break;
- case 4:
- case 6:
- case 9:
- case 11:
- i=30;
- break;
- case 2:
- i=29;
- break;
- }
- switch(k)
- {
- case 3:
- case 11:
- j=1;
- break;
- case 6:
- j=2;
- break;
- case 9:
- case 12:
- j=3;
- break;
- case 1:
- case 4:
- case 7:
- j=4;
- break;
- case 10:
- j=5;
- break;
- case 5:
- j=6;
- break;
- case 2:
- case 8:
- j=7;
- break;
- }
- cout<<"日 一 二 三 四 五 六"<<endl;
- int d=1,w=1,m=1;
- while(d<=i)
- {
- if(w<=7)
- {
- while(m<=j-1)
- {
- cout<<" "<<"\t";
- m=m+1;
- w=w+1;
- }
- cout<<d<<"\t";
- d=d+1;
- w=w+1;
- }
- else
- {
- cout<<endl;
- w=1;
- }
- }
- cout<<endl;
- system("pause");
- return 0;
- }
複製代碼 |