#include<iostream>
using namespace std;
//输入三个整数,按从小到大顺序输出
int main()
{
string str1, str2, str3;
cout << "请输入三个字符串:";
cin >> str1 >> str2 >> str3;
string* p1 = &str1, * p2 = &str2, * p3 = &str3;
if (*p1 > * p2)
{
string temp = *p1;
*p1 = *p2;
*p2 = temp;
}
if (*p1 > * p3)
{
string temp = *p1;
*p1 = *p3;
*p3 = temp;
}
if (*p2 > * p3)
{
string temp = *p2;
*p2 = *p3;
*p3 = temp;
}
cout << "从小到大排序:" << *p1 << " " << *p2 << " " << *p3 << endl;
return 0;
}
谭浩强c++第三版6-2
最新推荐文章于 2021-05-02 23:54:51 发布