111

我哩个骚钢  •  2个月前


#include <bits/stdc++.h>
using namespace std;

int main() {
	list<int>a;
	int x, k;
	while (1) {
		cin >> x;
		if (x == -1) {
			break;
		}
		a.push_back(x);
	}
	cin >> k;
	if (a.size() < k) {
		cout << "not found";
		return 0;
	}
	for (int i = 0; i < k-1; i++) {
		a.pop_back();
	}
	cout << a.back();
	return 0;
}

评论:

请先登录,才能进行评论