/*
* Copyright (c) 2013, 烟台大学计算机学院
* All rights reserved.
* 作 者: 申玉迪
* 完成日期:2013 年 11月 20日
* 版 本 号:v1.0
* 输入描述: 无
*/
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double a,c,d,i=0,j=0,m=0,n=0;
while(cin>>a)
{
if(a>0)
{
i+=1;
m=m+a;
}
else if(a<0)
{
j+=1;
n=n+a;
}
}
c=m/i;
n=-n;
d=n/j;
cout<<"涨的数目"<<i<<" "<<"跌的数目"<<j<<endl;
cout<<setiosflags(ios::fixed)<<setprecision(3)<<"平均涨幅"<<c<<" "<<"平均跌幅"<<d<<endl;
return 0;
}
对抗赛中,就是因为不会ctrl—z输出,一直看困惑着不知错哪了。这种方法原来不知道,以后还要多看一些有用的资料