Adolf Hitler • 5个月前
#include <bits/stdc++.h>
using namespace std;
int main() {
list<int>s1;
list<int>s2;
int n;
cin >> n;
while (n != -1) {
if (n != -1) {
s1.push_back(n);
}
cin >> n;
}
auto it = s2.begin();
for (auto t0 = s1.begin(); t0 != s1.end(); t0++) {
if (*t0 % 2 != 0) {
s2.insert(it, *t0);
}
}
if (s2.size() == 0) {
cout << "No";
return 0;
}
for (auto t1 = s2.begin(); t1 != s2.end(); t1++) {
if (*t1 % 2 != 0) {
cout << *t1 << " ";
}
}
return 0;
}
评论:
请先登录,才能进行评论