31 lines
381 B
C++
31 lines
381 B
C++
#include<iostream.h>
|
|
int main()
|
|
{
|
|
int i,a,b,c;
|
|
float sum,average;
|
|
sum=0;
|
|
i=0;
|
|
average=0;
|
|
b=0;
|
|
c=0;
|
|
cout<<"请输入整数:\n";
|
|
cin>>a;
|
|
while(a!=0)
|
|
{
|
|
sum=sum+a;
|
|
i++;
|
|
if(a>0)
|
|
b=b+1;
|
|
else
|
|
c=c+1;
|
|
cout<<"请输入整数:\n";
|
|
cin>>a;
|
|
}
|
|
average=sum/i;
|
|
cout<<"有正数:"<<b<<"个\n";
|
|
cout<<"有负数:"<<c<<"个\n";
|
|
cout<<"平均值为:"<<average<<endl;
|
|
return 0;
|
|
}
|
|
|