zoj 3492 Kagome Kagome

来源:互联网 发布:python免费吗 编辑:程序博客网 时间:2024/04/24 06:21
//这题需要注意就是:它给出的名字的排序是逆序来的!#include "iostream"#include "string"using namespace std;int main(){int testcase, num, i, ans;string name, str[110];cin >> testcase;while (testcase--){cin >> num >> name;for (i = 0; i < 110; i++)str[i] = "";ans = 0;for (i = 0; i < num; i++)cin >> str[i];for (i = 0; i < num; i++)//找出其在名字串中的位置!if (str[i] == name)break;ans = (i + num/2) % num;//求得在名字串中的位置!cout << str[ans] << endl;}}

原创粉丝点击