Description
请在一张 n个单词的序列中,输出第 k个单词。
Format
Input
第一行输入两个正整数 n,k(0<k≤n≤1000)。
第二行连续输入 n个单词,每个单词长度不超过 30,单词全部由小写英文字母构成。
Output
输出第 k个单词。
输入数据 1
5 2
one two three four five
输出数据 1
two
代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 5;
int main()
{
int a, b;
string c;
cin >> a >> b;
for (int i = 1; i <= a; ++i) {
cin >> c;
if (i == b) {
cout << c;
return 0;
}
}
return 0;
}