Đề bài:
Bài làm:
#include<stdio.h>
int main(){
int n,x=0,y=0;
scanf("%d",&n);
int a[n];
double s2=0,s1=0;
if(n>=0){
for (int i=0;i<n;i++){
scanf("%d",&a[i]);
if (a[i] > 0){
s1+=a[i];
x++;
} else if(a[i]<0){
s2+=a[i];
y++;
}
}
if(x==0){
printf("%lf Mang khong co so duong",s2/y);
}else if(y==0){
printf("%lf Mang khong co so am",s1);
}else if(x!=0 && y!=0){
printf("%lf %lf",s2/y,s1);
}
}
return 0;
}
cảm ơn m.n !
update 2/7/2021 : mình tìm ra được lỗi rồi, cảm ơn mọi người nhé.
lỗi ở đây do người viết lập trình chấm điểm thôi ạ.