题面
() 个字符指针组成一个数组,每个指针指向一个字符串。
通过该数组对其元素所指的字符串按以下顺序排序:按字符串中第一个数字字符的升序排序(不包含数字字符的字符串排在最前面)。若数字字符相同,则按字符串本身值的升序排序。使用 qsort
定义函数 SortStrings
。
void SortStrings(char *p[ ], int n);
/* PreCondition:
p points to an array with n pointers which point to strings
PostCondition:
array is sorted satisfying to the specification
*/
样例
输入
st123 ring
输出
ring st123
提示
#include <stdio.h>
#include <stdlib.h>
#define N 100
#define LEN 80
/* 你的代码将会被嵌入在这个地方 */
int main(){
/* 你不需要关心输入细节,隐藏不表 */
for ( /* 一定的代码逻辑 */ ) {
SortStrings(a,n); /* 函数会在这里被调用 */
for ( /* 一些后续处理和输出,你不应该关心 */) {
}
}
return 0;
}