编程菜鸟的日记-初学尝试编程-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; }

 

posted @ 2013-12-01 01:34  编程的爬行者  阅读(164)  评论(0编辑  收藏  举报