用二維字符數組方法編程實現從鍵盤任意輸入10個字符串,將這10個字符串按字典順序排序后打印輸出,字符串最大長度80。 **輸入提示信息格式: 無 **輸入數據格式要求: 要求讀入的字符串可以包含有空格 **輸出數據格式要求: 一行輸出一個字符串 注:不能使用指針、結構體、共用體、文件、goto、枚舉類型進行編程。
1 #include<stdio.h>
2 #include<string.h>
3 main()
4 {
5 char str[10][80], temp[80];
6 int i, j;
7 for (i = 0; i < 10; i++)
8 {
9 gets(str[i]);
10
11 }
12 for (i = 0; i < 9; i++)
13 {
14 for (j = i + 1; j < 10; j++)
15 {
16 if (strcmp(str[i], str[j]) > 0)
17 {
18 strcpy(temp, str[i]);
19 strcpy(str[i], str[j]);
20 strcpy(str[j], temp);
21 }
22 }
23 }
24 for (i = 0; i < 10; i++)
25 {
26 printf("%s\n", str[i]);
27 }
28 }