程序代码:
#include<stdio.h>
int main()
{
int a,sum1=0,sum2=0;
while(1)
{
printf("请输入一个自然数(输入负数结束输入):");
scanf("%d",&a);
if(a<0)
break;
if(a%2!=0)
sum1+=a;
else
sum2+=a;
printf("sum1=%d\nsum2=%d\n",sum1,sum2);
}
printf("sum1=%d\nsum2=%d\n",sum1,sum2);
return 0;
}