AC

⛴李恒旭(⓿_⓿)⚔♆§  •  1年前


include <bits/stdc++.h>

include

using namespace std;

int main() {

list<int>l;
int x, max = 0;
cin >> x;
while (x != -999) {
	l.push_back(x);
	cin >> x;
}
max = l.front();
auto i = l.begin();
while (i != l.end()) {
	if (*i > max) {
		max = *i;
	}
	i++;
}
list<int>::iterator j = l.begin();
while (j != l.end()) {
	if (*j == max) {
		if (*j == l.front() && *j == l.back()) {
			l.push_back(-25);
			l.push_front(-25);
		} else if (*j == l.front()) {
			j++;
			l.insert(j, -25);
			l.push_front(-25);
		} else if (*j == l.back()) {
			l.push_back(-25);
			l.insert(j, -25);
		} else {
			j++;
			l.insert(j, -25);
			j--;
			j--;
			l.insert(j, -25);
		}
		break;
	}
	j++;
}
for (auto i = l.begin(); i != l.end(); i++) {
	cout << *i << " ";
}
return 0;

}


评论:

我差点忘了,最后的for循环要加上l.clean();


⛴李恒旭(⓿_⓿)⚔♆§  •  1年前

二次元勿喷  •  9个月前

请先登录,才能进行评论