编程,输入一批整数,先求出其中的偶数和及奇数和,然后输出偶数和与奇数和的差.#include int main(){int a,sum1=0,sum2=0;printf("put data");scanf("%d,&a");for(scanf("%d",&n)!=EOF); if(n%2==0) sum1=sum1+a; else sum2=sum2+
来源:学生作业帮助网 编辑:六六作业网 时间:2025/01/04 02:54:01
编程,输入一批整数,先求出其中的偶数和及奇数和,然后输出偶数和与奇数和的差.#include int main(){int a,sum1=0,sum2=0;printf("put data");scanf("%d,&a");for(scanf("%d",&n)!=EOF); if(n%2==0) sum1=sum1+a; else sum2=sum2+
编程,输入一批整数,先求出其中的偶数和及奇数和,然后输出偶数和与奇数和的差.
#include
int main()
{
int a,sum1=0,sum2=0;
printf("put data");
scanf("%d,&a");
for(scanf("%d",&n)!=EOF);
if(n%2==0)
sum1=sum1+a;
else
sum2=sum2+a;
printf("sum1=%d\nsum2=%d",sum1,sum2 );
return 0;
}
请指点哪里错了!太多改动的给个例子参考一下
编程,输入一批整数,先求出其中的偶数和及奇数和,然后输出偶数和与奇数和的差.#include int main(){int a,sum1=0,sum2=0;printf("put data");scanf("%d,&a");for(scanf("%d",&n)!=EOF); if(n%2==0) sum1=sum1+a; else sum2=sum2+
#include
#include
int main()
{
int a,sum1=0,sum2=0;
printf("put data");
while(scanf("%d",&a)!=0)
{
if(a%2==0)
sum1=sum1+a;
else
sum2=sum2+a;
}
printf("sum1=%d\nsum2=%d",sum1,sum2 );
system("pause");
\x09return 0;
}