帮你一下!
#include<iostream>
#define Vol 3
class Array
{
private:
int k;
int t;
public:
void Initial(int tempk,int tempt)
{
k=tempk;
t=tempt;
}
int Get_k()
{
return k;
}
};
float func(Array M[],Array N[]);
void Initial(Array TempArray[]);
int main()
{
Array M[Vol];
Array N[Vol];
std::cout<<"Initializing the two Array!\n";
Initial(M);
Initial(N);
float Sum=0;
Sum=func(M,N);
std::cout<<"The Result is "<<Sum<<std::endl;
return 0;
}
float func(Array M[],Array N[])
{
int sum=0,i;
for(i=0;i<Vol;i++)
sum+=(M[i].Get_k()-N[i].Get_k());
if(sum<0)
sum=0-sum;
return (float)sum/(float)(Vol-2);
}
void Initial(Array TempArray[])
{
int Tk,Tt;
for(int i=0;i<Vol;i++)
{
std::cout<<"Array["<<i<<"]\n";
std::cin>>Tk>>Tt;
TempArray[i].Initial(Tk,Tt);
}
}