求数组中比x大的元素的个数问题

  1. 填空题
    打开解决方案文件proj2,此工程文件包含程序文件main.cpp,其中有类Array(“数组”)的定义和主函数main的定义。在主函数中定义了一个数组类的对象,程序实现了求数组中比x大的元素个数。请在程序中“//found”下的横线处填写适当的代码,然后删除横线,以实现上述类定义。

此程序的正确输出结果应为:

 数组为:

 6       8       3       9       4       2       1       7       5

 x为:5

 比5大的元素个数为:4

[程序]

//main.cpp

#include

using namespace std;

class Array{

public:

     Array(float *p,int m,float x1);           // 用p初始化a,m初始化n,x1初始化x

     ~Array();                                                 // 释放动态空间

     void print()const;                                  // 按指定格式输出结果

     void count();                                          // 计算比x大的元素个数

private:

     float *a,x;                                                        // 数组及指定的x

     int n;                                                                 // 数组大小(所有元素个数)

     static int number;                                  // 数组中比x大的元素个数

};

//found

__________________________ ;

Array::Array(float *p,int m,float x1):n(m),x(x1)

{

     int i;

     //**********found**********

     __________________________ ;

     for(i=0;i

               a[i]=p[i];

}

Array::~Array()

{

     //**********found**********

     __________________________ ;

}

void Array::print()const

{

     int i;

     cout<<"数组为:\n";

     for(i=0;i'\t';

     cout<<endl;

     cout<<"x为:"<endl;

     cout<<"比"<"大的元素个数为:"<endl;

}

void Array::count()

{

     int i;

     for(i=0;i
               //**********found**********

               _________________ number++;

}

int main()

{

     float t[9]={6,8,3,9,4,2,1,7,5};

     Array test(t,9,5.0);

     test.count();

     test.print();

     system("pause");

     return 0;

上面的程序需要found部分缺少代码,但是我写的代码都报错,运行不了,到底应该写什么啊?

遍历一遍数组不就行了