計算有幾個正整數為奇

給予多個正整數,請計算有幾個正整數為奇。 Input Format 輸入多個正整數,0則為結束。
 avatar
user_6817964
c_cpp
3 years ago
209 B
5
Indexable
#include <stdio.h>
int main()
{
    int sum = 0, n;
    while (scanf_s("%d", &n)) {
        if (n == 0)
            break;
        if (n % 2 != 0)
            sum++;
    }
    printf("%d", sum);
}
Editor is loading...