习题6.2
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
using namespace std;
int main() {
char str1[100], str2[100], str3[100], temp[100],
* p1, * p2, * p3, * p_temp = temp;
cout << "请输入第一个字符串str1:";
cin >> str1;
cout << "请输入第二个字符串str2:";
cin >> str2;
cout << "请输入第三个字符串str3:";
cin >> str3;
p1 = str1, p2 = str2, p3 = str3;
if ((strcmp(p1, p2)) > 0) {
strcpy(p_temp, p1);
strcpy(p1, p2);
strcpy(p2, p_temp);
}
if ((strcmp(p1, p3)) > 0) {
strcpy(p_temp, p1);
strcpy(p1, p3);
strcpy(p3, p_temp);
}
if ((strcmp(p2, p3)) > 0) {
strcpy(p_temp, p2);
strcpy(p2, p3);
strcpy(p3, p_temp);
}
cout << p1 << " " << p2 << " " << p3 << endl;
return 0;
}