水题,按条件判一下,考的时候不是这么写的,更简练一些,这题也可以用vector或者map写,更加精练一些
#include<iostream>#include<vector>#include<string>using namespace std;int main(){ string str[5005], fz[5005]; int n, m, k, s, i, j; scanf("%d %d %d", &m, &n, &s); for (i = 0; i < m; i++) { cin >> str[i]; } if (s> m) { cout << "Keep going..." << endl; return 0; } cout << str[s - 1] << endl; k = 0; int flag = 0; fz[k++] = str[s - 1]; for (i = s - 1 + n; i < m;) { for (j = 0; j < k; j++) { if (str[i] == fz[j]) { flag = 1; break; } } if (flag) { flag = 0; i++; } else { cout << str[i] << endl; fz[k++] = str[i]; i += n; } } return 0;}
新闻热点
疑难解答