7-25 求奇数和

 1 #include <stdio.h>
 2 
 3 int main(void)
 4 {
 5     int num;
 6     int sum = 0;
 7     while (1)
 8     {
 9         scanf("%d", &num);
10         if (num <= 0)
11         {
12             break;
13         }
14         else if (num % 2 == 1)
15         {
16             sum = sum + num;
17         }
18     }
19 
20     printf("%d", sum);
21 
22     return 0;
23 }

 

posted @ 2019-12-12 13:23  jason2018  阅读(182)  评论(0编辑  收藏  举报