Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
42964 纪哲弘 环形密码 C++ Accepted 2 MS 272 KB 1111 2022-12-03 13:25:00

Tests(10/10):


Code:

#include <iostream> #include <cstring> #include <cmath> #include <time.h> using namespace std; int currentIndex = 1; int searchArr(int arr[], int ct, int findCount) { int tmpCount = 1, i = currentIndex; while (tmpCount != findCount) { i = i % (ct + 1) != 0 ? i : 1; // cout << "i = " << i << " -> Value = " << arr[i] << endl; if (arr[i++] != 0) tmpCount++; } i = i > ct ? 1 : i; // cout << "ii = " << i << "=>" << arr[i] << endl; while (arr[i] == 0) { i++; i = i % (ct + 1) != 0 ? i : 1; }; currentIndex = i + 1; return i; } int main() { int count, b; cin >> count >> b; int pwd[101]; for (int i = 1; i <= count; i++) { int tmpnum; cin >> tmpnum; pwd[i] = tmpnum; // cout << pwd[i] << endl; } int index = 1; int f = 0; int num = 1; while (f != count) { if (index > count) index = 1; if (pwd[index] == -1) { index++; continue; } if (num == b) { f++; num = 1; b = pwd[index]; pwd[index] = -1; cout << b << ' '; } else num++; index++; } cout << endl; return 1; }