計算并輸出數(shù)組中所有正數(shù)之和所有負數(shù)之和?
#include<stdio.h>
void main()
{
int i,j,b[3][4],s1=0,s2=0;
printf("請輸入數(shù)組:\n");
for(i=0;i<3;i++)
for(j=0;j<4;j++)
{
scanf("%d",&b[i][j]);
if(b[i][j]>0)
s1+=b[i][j];
else
s2+=b[i][j];
}
printf("所有正數(shù)之和為:%d\n",s1);
printf("所有負數(shù)之和為:%d\n",s2);
}