- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int day,start;
- cout<<"請輸入該月的天數(28~31): ";
- cin>>day;
- cout<<"請輸入該月的一號落在第一週的第幾天(1~7): ";
- cin>>start;
-
- cout<<endl<<"日\t一\t二\t三\t四\t五\t六"<<endl;
-
- for(int i=1;i<=day+(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");
- return 0;
- }
複製代碼 |