返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int day,start;
  7.     cout<<"請輸入該月的天數(28~31): ";
  8.     cin>>day;
  9.     cout<<"請輸入該月的一號落在第一週的第幾天(1~7): ";
  10.     cin>>start;
  11.    
  12.     cout<<endl<<"日\t一\t二\t三\t四\t五\t六"<<endl;
  13.         
  14.     for(int i=1;i<=day+(start-1);i++)
  15.     {
  16.         if(i<start)
  17.         {
  18.             cout<< '\t';        
  19.         }     
  20.         else
  21.         {
  22.             cout<<i-(start-1)<<'\t';  
  23.         }
  24.         if(i%7==0)
  25.             cout<<endl;
  26.     }                    
  27.     cout<<endl<<endl;;   
  28.     system("pause");   
  29.     return 0;
  30. }
複製代碼

TOP

返回列表