|
这是我的头文件
#ifndef CACULATE_H
#define CACULATE_H
#include "math.h"
class NumberCaculate{
private:
int number[20];
int num;
public:
int setNum(int i);
int setNumber(int i);
float getMean(int i);
float getVariance(int i);
float getStdDeviation();
};
float NumberCaculate::getMean(int i){
int j=0;
float sum=0;
for(j=0;j<=i;j++){
sum=sum+number[j];
}
return sum/i;
}
float NumberCaculate::getVariance(int i){
float sum=0;
int j=0;
for(j=0;j<=i;j++){
sum=sum+(getMean(num))*(getMean(num));
}
return sum/i;
}
float NumberCaculate::getStdDeviation(){
return sqrt(getVariance(num));
}
int NumberCaculate::setNumber(int i){
return number;
}
int NumberCaculate::setNum(int i){
return num;
}
#endif
现在我在我的main函数中需要cin个数据进入number【20】该怎么写啊?? |
|