返回列表 發帖
本帖最後由 鐘彥博 於 2020-6-25 20:59 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     system("cls");
  8.     int a,b,mou;
  9.     cout<<"[2020年月曆]"<<endl;
  10.         cout<<endl;
  11.     cout<<"請輸入想知道的月份(1~12):";
  12.     cin>>mou;
  13.     cout<<endl;
  14.     switch(mou)
  15.     {
  16.             case 1:
  17.             b=4;a=31;
  18.             break;
  19.             case 2:
  20.             b=7;a=29;
  21.             break;
  22.             case 3:
  23.             b=1;a=31;
  24.             break;
  25.             case 4:
  26.             b=4;a=30;
  27.             break;
  28.             case 5:
  29.             b=6;a=31;
  30.             break;
  31.             case 6:
  32.             b=2;a=30;
  33.             break;
  34.             case 7:
  35.             b=4;a=31;
  36.             break;
  37.             case 8:
  38.             b=7;a=31;
  39.             break;
  40.             case 9:
  41.             b=3;a=30;
  42.             break;
  43.             case 10:
  44.             b=5;a=31;
  45.             break;
  46.             case 11:
  47.             b=1;a=30;
  48.             break;
  49.             case 12:
  50.             b=3;a=31;
  51.             break;
  52.             default:
  53.             cout<<"Please try to read what I wrote on the screen!"<<endl;
  54.                 system("pause");
  55.                 goto re;       
  56.         }
  57.     cout<<"日\t一\t二\t三\t四\t五\t六"<<endl;
  58.     for(int j=1;j<=a+b-1;j++)
  59.     {
  60.     if(j<b)
  61.     {
  62.     cout<<" \t";
  63.     }else
  64.     {
  65.          cout<<j-(b-1)<<" \t";
  66.     }
  67.     if(j%7==0)
  68.     {
  69.     cout<<endl;
  70.     }
  71.     }
  72.     cout<<endl;
  73.     cout<<endl;
  74.     system("pause");
  75.     goto re;
  76.     system("pause");
  77.     return 0;
  78. }
複製代碼

TOP

返回列表