#include<iostream>
using namespace std;
class A{
public:
A(int a,int b,int c)
{
x=a;
y=b;
z=c;
}
~A(){
}
void compare()
{
if((this->x)>(this->y)&&(this->x)>(this->z))
{
cout<<this->x<<endl;
}else if((this->y)>this->z)
{
cout<<this->y<<endl;
}else cout<<this->z<<endl;
}
private:
int x,y,z;
};
int main()
{
A a1(2,3,4);
a1.compare();
A a2(4,3,1);
a2.compare();
A a3(3,5,3);
a3.compare();
return 0;
}
用指针比较三个数字大小
最新推荐文章于 2023-12-03 17:22:33 发布