返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     system("cls");
  8.     int x,y,z;
  9.     cout<<"[2020年月曆]"<<endl;
  10.         cout<<endl;
  11.     cout<<"請輸入想知道的月份(1~12):";
  12.     cin>>z;
  13.     cout<<endl;
  14.     switch(z)
  15.     {
  16.             case 1:
  17.             y=4;x=31;
  18.             break;
  19.             case 2:
  20.             y=7;x=29;
  21.             break;
  22.             case 3:
  23.             y=1;x=31;
  24.             break;
  25.             case 4:
  26.             y=4;x=30;
  27.             break;
  28.             case 5:
  29.             y=6;x=31;
  30.             break;
  31.             case 6:
  32.             y=2;x=30;
  33.             break;
  34.             case 7:
  35.             y=4;x=31;
  36.             break;
  37.             case 8:
  38.             y=7;x=31;
  39.             break;
  40.             case 9:
  41.             y=3;x=30;
  42.             break;
  43.             case 10:
  44.             y=5;x=31;
  45.             break;
  46.             case 11:
  47.             y=1;x=30;
  48.             break;
  49.             case 12:
  50.             y=3;x=31;
  51.             break;
  52.             default:
  53.             cout<<"請嘗試閱讀我在屏幕上寫的內容!"<<endl;
  54.                 system("pause");
  55.                 goto re;      
  56.         }
  57.     cout<<"日\t一\t二\t三\t四\t五\t六"<<endl;
  58.     for(int j=1;j<=x+y-1;j++)
  59.     {
  60.     if(j<y)
  61.     {
  62.     cout<<" \t";
  63.     }else
  64.     {
  65.          cout<<j-(y-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

返回列表