题解分享
题解分享简介
奇偶统计改 - 题解
include
using namespace std;
int main()
{
int n;
int count = 0, sum = 0;
while (cin >> n) {
if (n % 2 == 0) {
count++;
}
else
{
sum += n;
}
}
cout << count << endl << sum;
return 0;
//再复制之后按下快捷键ctrl+z来结束输入
}
查看全文
0
0
0
1
奇偶统计改 - 题解
```cpp
#include <bits/stdc++.h>
using namespace std;
int i;
int num_even = 0;
int num_odd = 0;
int main() {
while(cin >> i)
if (i % 2 == 0)
num_even++;
else
num_odd += i;
cout << num_even << endl << num_odd << endl;
return 0;
}
```
查看全文
0
0
0
1
奇偶统计改 - 题解
```
#include <iostream>
using namespace std;
int a,ans,n;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
while(cin>>a)
{
if(a==0)break;
if(a%2==0){
n++;
}
else
ans+=a;
}
cout<<n<<"\n"<<ans;
return 0;
}
```
查看全文
0
0
0
2
奇偶统计改 - 题解
```
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int count = 0;
int sum = 0;
String s = sc.nextLine();
sc.close();
String[] strArray = s.split(" "); // 使用一个空白字符作为分隔符
int[] intArray = new int[strArray.length];
for (int i = 0; i < strArray.length; i++) {
intArray[i] = Integer.parseInt(strArray[i]); // 将每个子字符串转换为整数
}
for (int i = 0; i < intArray.length; i++) {
if (intArray[i] % 2 == 0) {
count += 1;
} else {
sum += intArray[i];
}
}
System.out.println(count);
System.out.println(sum);
}
}
```
查看全文
0
0
0
1
奇偶统计改 - 题解
```
//模板
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define INF 0x3f3f3f3f3f3f3f3f
#define int long long
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n , cnt = 0 , ans = 0;
while(cin >> n)
{
if(n % 2 == 0)
{
cnt++;
}
else{
ans += n;
}
}
cout << cnt << endl << ans ;
return 0;
}
```
查看全文
0
0
0
1



