【求帮助】输入10个正数,编程奇数和偶数的和(简单的)
求帮助
不解
[ 本帖最后由 yuccn 于 2011-5-14 10:55 编辑 ]
#include <stdio.h> #include <stdlib.h> int main(void) { int num[10], i = 0, even = 0, oddNumber = 0; printf("Enter next integer: "); while(i < 10) { if(scanf("%d", num + i) != 1) { printf("Error, Program will to exit. Bye!\n"); exit(1); } i++; printf("Enter next integer: "); } for(i = 0; i < 10; i++) { if(num[i] % 2) { oddNumber += num[i]; } else { even += num[i]; } } printf("The total of even : %d\n", even); printf("The total of oddNumber %d\n", oddNumber); return 0; }