题解 | A30691.求奇偶数之和
2026-02-08 17:30:54
发布于:广东
6阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int n , a[5010];
int s1 , s2;
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> a[i];
}
for(int i = 1;i <= n;i++){
if(a[i]%2 != 0){ //判断是否为奇数
s1 += a[i];
}
else{
s2 += a[i];
}
}
cout << s1 << "\n" << s2;
return 0;
}
这里空空如也


有帮助,赞一个