#include <stdio.h>int main (void){ int o_sum, j_sum, o_count, j_count, n; double o_ave, j_ave; o_sum = j_sum = 0.0; o_count = j_count = 0; while ((scanf ("%d",&n) == 1) && (n != 0) ) { if (n % 2 == 0) { o_count++; o_sum += n; } else { j_count++; j_sum += n; } } printf ("有偶数%d个",o_count); if (o_count > 0) { o_ave = o_sum / o_count; printf ("偶数平均值为%lf",o_ave); } printf ("奇数有%d个",j_count); if (j_count > 0) { j_ave = j_sum / j_count; printf ("奇数平均值为%lf",j_ave); } system("pause"); return 0;}
添加回答
举报
0/150
提交
取消