奇数个数

xiaoxiao2021-02-28  127

奇数个数

时间限制: 1000 ms  |  内存限制: 65535 KB 难度: 1 描述   现在让你任意输入10个整数,任务是:统计出其中奇数的个数。 输入 多组数据,以EOF结束。任意输入10个整数(int型范围内) 输出 输出其中奇数的个数 样例输入 1 2 3 4 5 6 7 8 9 10 样例输出 5

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int count = 0; while (scanner.hasNext()) { int number = scanner.nextInt(); if (number % 2 == 1) { count++; } } System.out.println(count); } }

转载请注明原文地址: https://www.6miu.com/read-26633.html

最新回复(0)