Seeking odd and

This problem requires calculation of a given set of odd positive integers and.

Input format:
input given positive integer number in a row, separated by a space therebetween. When read zero or negative integer representing the input end, the numbers do not deal with.
Output format:
output sequence of odd positive integers and in a row.
Sample input:
87437056101-1
Output Sample:
116

#include<stdio.h>
int main(){
    int x;
    int s=0;
    while(1){
        scanf("%d ",&x);
        if(x<=0)break;
        else if(x%2==1)s+=x;
    }
    printf("%d",s);
    return 0;
}
Published 17 original articles · won praise 12 · views 264

Guess you like

Origin blog.csdn.net/qq_45894099/article/details/105207342