locale-test/9-4-2-201309060289-wanghuiy.../王惠宇第三次上机作业/01.cpp

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;
}