63 条题解
-
0
#include <iostream> using namespace std; int main() { int n,a[30],even[30],odd[30]; cin >> n; for (int i = 0;i<n;i++) { cin >> a[i]; } int ei = 0,oi = 0; for(int i = 0;i<n;i++) { if(a[i]%2 ==0) { even[ei] = a[i]; ei ++; } else { odd[oi] = a[i]; oi ++; } } for (int i = 0;i<oi;i++) { cout << odd[i] << " "; } cout << endl; for (int i = 0;i<ei;i++) { cout << even[i] << " "; } return 0; }
-
0
#include <iostream> using namespace std; int main() { int n, a[250];//嘿嘿,瓦就要写250 cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { if (a[i] % 2 == 1) { cout << a[i] << " "; } } cout << endl; for (int i = 0; i < n; i++) { if (a[i] % 2 == 0) { cout << a[i] << " "; } } return 0; }
-
0
#include <iostream> using namespace std; int main() { int n, a[100]; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { if (a[i] % 2 == 1) { cout << a[i] << " "; } } cout << endl; for (int i = 1; i <= n; i++) { if (a[i] % 2 == 0) { cout << a[i] << " "; } } return 0; }
😄 👍
-
0
#include <iostream> using namespace std; int main() { int n,a[30]; cin>>n; for (int i=0;i<n;i++) { cin>>a[i];//输入 if (a[i]%2==1)//判断奇数 { cout<<a[i]<<" ";//输出奇数 } } cout<<endl;//换行 for (int i=0;i<n;i++) { if (a[i]%2==0)//判断偶数 { cout<<a[i]<<" ";//输出偶数 } } return 0; }
编程不易😕 ,赞在哪里👀️ ?
-
0
#include <bits/stdc++.h> using namespace std; int main() { int n, a[100], odd[100], even[100]; cin >> n; for (int i=1;i<=n;i++) cin >> a[i]; for (int i=1;i<=n;i++) if (a[i] % 2 == 1) cout << a[i] << " "; cout << endl; for (int i=1;i<=n;i++) if (a[i] % 2 == 0) cout << a[i] << " "; return 0; } //编写不易啊,先点赞再溜可以吗!😕
-
0
#include <iostream> using namespace std; int main() { int n,a[30]; cin >> n; for (int i = 0;i < n;i++) { cin >> a[i];//输入每个数 } for (int i = 0;i < n;i++) { if (a[i] % 2 == 1)//判断是否是奇数 { cout << a[i] << " ";//输出奇数 } }
cout << endl;//换行 for (int i = 0;i < n;i++) { if (a[i] % 2 == 0)//判断是否是偶数 { cout << a[i] << " ";//输出偶数 } }//不要忘了输出时加空格 return 0;
}
-
0
#include <iostream> using namespace std; int main() { int n,a[30]; cin >> n; for (int i = 0;i < n;i++) { cin >> a[i]; } for (int i = 0;i < n;i++) { if (a[i] % 2 == 1) { cout << a[i] << " "; } } cout << endl; for (int i = 0;i < n;i++) { if (a[i] % 2 == 0) { cout << a[i] << " "; } } return 0; }
-
0
#include <iostream> using namespace std; int main() { int n,a[30]; cin >> n; for (int i = 0;i < n;i++) { cin >> a[i]; } for (int i = 0;i < n;i++) { if (a[i] % 2 == 1) { cout << a[i] << " "; } } cout << endl; for (int i = 0;i < n;i++) { if (a[i] % 2 == 0) { cout << a[i] << " "; } } return 0; }
-
0
#include <iostream> using namespace std; int main() { int n,a[30]; cin >> n; for (int i = 0;i < n;i++) { cin >> a[i];//输入每个数 } for (int i = 0;i < n;i++) { if (a[i] % 2 == 1)//判断是否是奇数 { cout << a[i] << " ";//输出奇数 } } cout << endl;//换行 for (int i = 0;i < n;i++) { if (a[i] % 2 == 0)//判断是否是偶数 { cout << a[i] << " ";//输出偶数 } }//不要忘了输出时加空格 return 0; }
-
0
#include <iostream> using namespace std; int main() { int n,a[30]; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { if (a[i] % 2 == 1) { cout << a[i] << " "; } } cout << endl; for (int i = 0; i < n; i++) { if (a[i] % 2 == 0) { cout << a[i] << " "; } } return 0; }
-
0
题解
接下来的事情很重要
一定要认真看
输出奇数的时候要加空格
中间要换行
输出偶数时也要加空格
千万别忘记
#include <iostream> using namespace std; int main() { int a[30], n; cin >> n;//输入数的个数 for (int i = 0; i < n; i++) { cin >> a[i];//依次输入这些数 } for (int i = 0; i < n; i++) { if (a[i] % 2 == 1)//判断是否为奇数 { cout << a[i] << " ";//输出奇数,空格一定要加上 } } cout << endl;//千万不要漏掉换行 for (int i = 0; i < n; i++) { if (a[i] % 2 == 0)//判断是否为偶数 { cout << a[i] << " ";//输出偶数,也要注意加空格 } } return 0; }
我这不是废话真的很重要 -
0
新手在此🎉️ 思路:遍历数组,奇数偶数运算
#include<iostream> using namespace std; int main() { int n , a[30]; cin >> n; for (int i = 0;i < n;i++) { cin >> a[i]; if (a[i] % 2 != 0)//第一次判断我放在循环里面了,循环里直接输出奇数 { cout << a[i] << " "; } } cout << endl;//换行不要忘记 for (int i = 0;i < n;i++)//遍历数组输出偶数 { if (a[i] % 2 == 0) { cout << a[i] << " "; } } return 0; }
不对请纠错
看完点个赞再走呀❤️
信息
- ID
- 158
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 5
- 标签
- 递交数
- 7772
- 已通过
- 2952
- 上传者