输入:整数个数n n个整数
输出:整数中负数的个数 正整数的均数
<pre name="code" class="cpp">#include <iostream>
#include<iomanip>
using namespace std;
int main()
{
int n,nega=0,posi=0,total=0;
cin >> n;
int* ARR =new int[n];
for (int i = 0;i < n;i++)
{
cin >> ARR[i];
if (ARR[i] < 0)
nega++;
else if (ARR[i]>0)
{
posi++;
total += ARR[i];
}
}
cout << nega << ' ';
if (posi > 0)
{
if (total%posi == 0)
{
int aver = total / posi;
cout << nega << ' ' << aver << endl;
}
else
{
float aver = ((float)total) / posi;
cout <<fixed<< setprecision(1) << aver << endl;
}
}
else
cout << 0;
return 0;
}