字串的连接最长路径查找
字串的连接最长路径查找
http://www.nowcoder.com/questionTerminal/5af18ba2eb45443aa91a11e848aa6723
#include <stdio.h> #include <string.h> int main(void) { char str[1000][100]; int num; scanf("%d", &num); for (int i = 0; i < num; i++) scanf("%s", str[i]); for (int i = 0; i < num; i++) for (int j = 0; j < num - i - 1; j++) for (int k = 0; k < 100; k++) { if (str[j][k] > str[j + 1][k]) { for (int m = 0; m < 100; m++) { int tem = str[j][m]; str[j][m] = str[j + 1][m]; str[j + 1][m] = tem; } break; } else if (str[j][k] < str[j + 1][k]) break; } for (int i = 0; i < num; i++) printf("%s\r\n", str[i]); return 0; }