#include<cstdio>
#include<iostream>
#include <cmath>
#include<string>
#include<algorithm>
#include<set>
#include<queue>
#include<iterator>
#include<cstring>
void swap(char *p, char *q)
{
char t[20];
strcpy(t, p);
strcpy(p, q);
strcpy(q, t);
}
int main()
{
char str1[20], str2[20], str3[20];
printf("input three string:\n");
scanf("%s%s%s", &str1, &str2, &str3);
if(strcmp(str1, str2)) swap(str1, str2);
if(strcmp(str1, str3)) swap(str1, str3);
if(strcmp(str2, str3)) swap(str2, str3);
printf("排好序的字符串:\n");
printf("%s %s %s\n", str1, str2, str3);
getchar();
return 0;
}
用指针将字符串从小到大排序
最新推荐文章于 2022-12-07 01:08:34 发布