int a,b,c;
cout<<"enter 3 numbers"<<endl;
cin>>a>>b>>c;
#include <iostream>
#include <cstdlib>
#include <ctime>
void sort(int,int,int);
using namespace std; //注意,函数原型后面必须加双引号
void main()
{
sort(a,b,c);
}
void sort(int a,int b,int c)
{
int *p1 = &a;
int *p2 = &b;
int *p3 = &c;
int *temt;
if(a<b)
{
temt=&a;
p1 = &b;
p2 = temt;
}
if (*p1<c)
{
temt = p1;
p1 = &c;
p3 = temt;
}
if (*p2<*p3)
{
temt = p2;
p2 = p3;
p3 = temt;
}
cout<<" "<<*p1<<" "<<*p2<<" "<<*p3<<endl;
}
cout<<"enter 3 numbers"<<endl;
cin>>a>>b>>c;
#include <iostream>
#include <cstdlib>
#include <ctime>
void sort(int,int,int);
using namespace std; //注意,函数原型后面必须加双引号
void main()
{
sort(a,b,c);
}
void sort(int a,int b,int c)
{
int *p1 = &a;
int *p2 = &b;
int *p3 = &c;
int *temt;
if(a<b)
{
temt=&a;
p1 = &b;
p2 = temt;
}
if (*p1<c)
{
temt = p1;
p1 = &c;
p3 = temt;
}
if (*p2<*p3)
{
temt = p2;
p2 = p3;
p3 = temt;
}
cout<<" "<<*p1<<" "<<*p2<<" "<<*p3<<endl;
}