1. 编写c程序完成从键盘输入10个整数存入一维数组中,计算奇数元素之和及偶数元素之和

2024-11-17 18:38:09
推荐回答(1个)
回答1:

#define N 10
main()
{
int a[N];
int i,t,sum1=0,sum2=0;
for (i=0;i scanf("%d",&a[i]);
for (i=0;iif(a[i]%2!=0) sum1+=a[i];
else sum2+=a[i];
printf("%d,%d",sum1,sum2);
}