提交时间:2024-12-12 16:59:26

运行 ID: 58542

#include <iostream> #include <algorithm> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> nums(n); for (int i = 0; i < n; i++) { cin >> nums[i]; } sort(nums.begin(), nums.end()); int flag = 0; for (int i = 0; i < n; i++) { if (nums[i] % 2 == 1) { if(flag == 1) cout << ","; cout << nums[i]; flag = 1; } } return 0; }