标签:col clu out return amp bsp class namespace std
思路:
质数一定是奇数。
实现:
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int n, t, x, y; 6 while (cin >> n) 7 { 8 x = y = 0; 9 for (int i = 1; i <= n; i++) 10 { 11 cin >> t; 12 if (t & 1) x++; 13 else y++; 14 } 15 if (!y) 16 { 17 while (x) { cout << "1 "; x--; } 18 cout << endl; 19 } 20 else 21 { 22 cout << "2 "; y--; 23 if (x) { cout << "1 "; x--; } 24 while (y) { cout << "2 "; y--; } 25 while (x) { cout << "1 "; x--; } 26 cout << endl; 27 } 28 } 29 return 0; 30 }
标签:col clu out return amp bsp class namespace std
原文地址:https://www.cnblogs.com/wangyiming/p/10798761.html