Miyago147852

PN - 體育課表

Oct 13th, 2022
1,309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #pragma GCC optimize("O3")
  3. #define endl "\n"
  4. #define endll "\n\n"
  5. #define pb push_back
  6. #define IO ios_base::sync_with_stdio(0);cin.tie(0)
  7. #define ll long long
  8. #define inf 0x3f3f3f3f
  9. #define MAXN inf
  10. #define DD(x) cout << #x << " = " << x << endl
  11.  
  12. using namespace std;
  13.  
  14. class Solution{
  15.     public:
  16.  
  17.     private:
  18.  
  19. };
  20.  
  21. string subjects[] = {"籃球", "排球", "田徑", "羽桌球", "休閒活動", "足壘球"};
  22. string places[] = {"A場地", "排球場", "C場地", "中山堂", "E場地", "中山堂旁階梯"};
  23. int ds[] = {0, 31, 61, 92, 122, 153};
  24.  
  25. signed main(){
  26.     // IO;
  27.     #ifdef DEBUG
  28.         string rootPath = "./";
  29.         freopen((rootPath+"t.in").c_str(), "r", stdin);
  30.         freopen((rootPath+"t.out").c_str(), "w", stdout);
  31.     #endif
  32.  
  33.     // TODO
  34.  
  35.     string error = "輸入錯誤";
  36.     string inputMonth = "請輸入月份:";
  37.     string inputDay = "請輸入日期:";
  38.     int month, day, week;
  39.  
  40.     // while (cin >> month >> day){
  41.     while (1){
  42.         cout << inputMonth << endl; cin >> month;
  43.         cout << inputDay << endl; cin >> day;
  44.         month = month + (month==1?12:0) - 8;
  45.         if (month < 0 || month > 5) {
  46.             cout << error << endl; continue;
  47.         }
  48.         week = ds[month] + day - 26;
  49.         if (week < 1 || week >= 21*7) {
  50.             cout << error << endl; continue;
  51.         }
  52.         week = week/7 + 1;
  53.         cout << "第" << week << "週" << endl;
  54.         cout << "課程內容: " << subjects[week%6].c_str()
  55.             << ", 上課地點: " << places[week%6].c_str() << endll;
  56.     }
  57.    
  58.  
  59.     return EXIT_SUCCESS;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment