- 最後登錄
- 2024-4-26
- 在線時間
- 28991 小時
- 註冊時間
- 2011-12-11
- 閱讀權限
- 95
- 精華
- 3
- UID
- 10643381
- 帖子
- 3222
- 積分
- 24364 點
- 潛水值
- 77150 米
| 如果發覺自己無法使用一些功能或出現問題,請按重新整理一次,並待所有網頁內容完全載入後5秒才進行操作。 本帖最後由 snowflying 於 2015-6-11 04:38 AM 編輯
C++ 參考看看吧
- #include <iostream>
- #include <cstdlib>
- #include <cstring>
- #include <algorithm>
- #define N 5
- using namespace std;
- struct Round
- {
- int val[3];
-
- }rd[N];
- int main()
- {
- int cnt[7] = {};
- int input[3];
- int idx = 0;
-
- memset(rd , 0 , sizeof(rd));
-
- while(cin >> input[0] >> input[1] >> input[2])
- {
- cnt[rd[idx].val[0]]--;
- cnt[rd[idx].val[1]]--;
- cnt[rd[idx].val[2]]--;
-
- cnt[rd[idx].val[0] = input[0]]++;
- cnt[rd[idx].val[1] = input[1]]++;
- cnt[rd[idx].val[2] = input[2]]++;
-
- int cnt_idx[6] = {1 , 2 , 3 , 4 , 5 , 6};
- for(int i = 0 ; i < 5 ; ++i)
- for(int j = 0 ; j < 5 ; ++j)
- if(cnt[cnt_idx[j]] < cnt[cnt_idx[j + 1]])
- swap(cnt_idx[j] , cnt_idx[j + 1]);
-
- for(int i = 0 ; i < 6 ; ++i)
- cout << cnt_idx[i] << " (" << cnt[cnt_idx[i]] << ") ";
- cout << endl;
-
- idx = (idx + 1) % N;
- }
- system("pause");
- return 0;
- }
複製代碼
... |
|