代码拉取完成,页面将自动刷新
#include<iostream>
using namespace std;
int main() {
int n, a;
while (cin >> n) {
int result = 0;
while (n != 0) {
a = (n % 10);
n = n / 10;
if (a % 2 == 0) result += a;
}
cout << result << endl;
cout << endl;
}
}
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNextInt()) {
int n = in.nextInt();
int res = 0;
while (n > 0) {
int tmp = n % 10;
if (tmp % 2 == 0) {
res += tmp;
}
n /= 10;
}
System.out.println(res);
System.out.println();
}
}
}
while 1:
try:
n=input()
s=0
for i in n:
if int(i)%2 == 0:
s += int(i)
print(s)
print()
except:
break
package main
import (
"fmt"
)
func main() {
var n, a, result int
for {
_, err := fmt.Scanf("%d", &n)
if err != nil || n == 0 {
break
}
result = 0
for n != 0 {
a = n % 10
n = n / 10
if a%2 == 0 {
result += a
}
}
fmt.Println(result)
fmt.Println()
}
}
const readline = require("readline");
const r1 = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const iter = r1[Symbol.asyncIterator]();
const read_line = async () => (await iter.next()).value;
let line = null;
(async function () {
while ((line = await read_line())) {
const arr = line.split("").map((item) => Number(item));
let sum = 0;
for (let i = 0; i < arr.length; i++) {
if (arr[i] % 2 === 0) {
sum += arr[i];
}
}
console.log(sum, "\n");
}
})();
#include <stdio.h>
int main() {
int n, a;
while (scanf("%d", &n) == 1) {
int result = 0;
while (n != 0) {
a = n % 10;
n = n / 10;
if (a % 2 == 0) result += a;
}
printf("%d\n\n", result);
}
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。