//谁又能单用a[i]存三个数了,自然是三个数组
#include<iostream>
using namespace std;
const short COUNT=3;
class rectangle
{
private:
float length;
float width;
float height;
public:
void Set(float l,float w,float h){length=l;width=w;height=h;}
float GetVolume(){return length*width*height;}
};
int main()
{
float l[COUNT],w[COUNT],h[COUNT];
rectangle MyRect[COUNT];
for(short i=0;i<COUNT;i++)
{
cout<<"请输入第"<<i+1<<"个长方体的数据:\n";
cout<<"长:";cin>>l[i];
cout<<"宽:";cin>>w[i];
cout<<"高:";cin>>h[i];
MyRect[i].Set(l[i],w[i],h[i]);
}
for(i=0;i<COUNT;i++)
{
cout<<"第"<<i+1<<"个长方体体积: "<<MyRect[i].GetVolume()<<endl;
}
return 0;
}