1:有三个字符串分别是:"hello" "bit" "world".然后排序之后输出的顺序为:"bit" "hello" "world
int main()
{
char str1[100];
char str2[100];
char str3[100];
char tmp[100];
scanf("%s", str1);
scanf("%s", str2);
scanf("%s", str3);
if (strcmp(str1, str2) > 0)//如果str1大于str2交换
{
strcpy(tmp, str1);
strcpy(str1, str2);
strcpy(str2, tmp);
}
if (strcmp(str1, str3) > 0)
{
strcpy(tmp, str1);
strcpy(str1, str3);
strcpy(str3, tmp);
}
if (strcmp(str2, str3) > 0)
{
strcpy(tmp, str2);
strcpy(str2, str3);
strcpy(str3, tmp);
}
printf("%s\n", str1);
printf("%s\n", str2);
printf("%s\n", str3);
system("pause");
return 0;
}
2.输入5个字符串,