//注意哦,这是C++,不是C哦。
#include <iostream>
using namespace std;
//定义函数Max
void Max(int *a,int *b,int *c)
{
int t;
if(*a<=*b&&*a<=*c)//在进行大小比较的时候一定不能少了指针符号
{ //因为在进行比较的是指针所指向地址的数,而不是地址
if(*b>=*c)
{
t=*b;
*b=*c;
*c=t;
}
}
else if(*b<=*a&&*b<=*c)
{
t=*b;
*b=*a;
*a=t;
if(*b>=*c)
{
t=*b;
*b=*c;
*c=t;
}
}
else if(*c<=*a&&*c<=*b)
{
t=*a;
*a=*c;
*c=t;
if(*b>=*c)
{
t=*b;
*b=*c;
*c=t;
}
}
cout<<*a<<" "<<*b<<" "<<*c<<endl;
}
int main()
{
int a,b,c;
cin>>a>>b>>c;
Max(&a,&b,&c);//一定要注意,这里传递的是地址
cout<<a<<" "<<b<<" "<<c<<endl;//注意输出格式
return 0;
}
当然这也只是其中的一种,小伙伴们也可以把自己的方法发出来,我们一起学习哦