题解 | #记负均正#
记负均正
https://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8
#include <iostream> using namespace std; int main() { int a,c=0,num; float d=0,e=0; cin>>a; int b[a]; for (int i=0; i<a; i++) { cin>>num; b[i]=num; } for (int i=0; i<a; i++) { if (b[i]<0) { c++; } else if(b[i]>0){ d=d+b[i]; e++; } } d=d==0?0:d/e; //cout<<b[1]; printf("%d %.1f" ,c,d); }