编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习2
#include <iostream> #include <cctype> using namespace std; const int MAXSIZE=10; int main() { double dd[MAXSIZE]; double donation; double aver=0; int num=0; int i=0; while(i<MAXSIZE && cin>>donation && !isdigit(donation)) { dd[i]=donation; aver+=dd[i]; i++; //(cin>>donation).get();
}
if(i) aver=aver/i; else aver=0; for(int j=0;j<i;j++)
if(dd[j]>aver)
num++; cout<<"aver= "<<aver<<endl; cout<<"num= "<<num<<endl; system("pause"); return 0; }