#include<iostream>
using namespace std;
//输入三个整数,按从小到大顺序输出
int main()
{
int a, b, c;
cout << "请输入三个整数:";
cin >> a >> b >> c;
int* p1 = &a, * p2 = &b, * p3 = &c;
if (*p1 > * p2)
{
int temp = *p1;
*p1 = *p2;
*p2 = temp;
}
if (*p1 > * p3)
{
int temp = *p1;
*p1 = *p3;
*p3 = temp;
}
if (*p2 > * p3)
{
int temp = *p2;
*p2 = *p3;
*p3 = temp;
}
cout << "从小到大排序:" << *p1 << " " << *p2 << " " << *p3 << endl;
return 0;
}
谭浩强c++第三版6-1
最新推荐文章于 2020-03-30 14:47:48 发布