如何对输入的指定个数的字符串进行按字典序排序?

来源:百度知道 编辑:UC知道 时间:2024/05/30 10:16:10
输入一定数量的字符串,然后按字典序排序。例如,
10
tiny
2short4me
very_long_file_name
shorter
size-1
size2
size3
much_longer_name
12345678.123
mid_size_name
应输出
12345678.123
2short4me
mid_size_name
much_longer_name
shorter
size-1
size2
size3
tiny
very_long_file_name

1. 有N个学生,每个学生的数据包括学号、姓名、性别,年龄,班级、C语言成绩。从键盘输入N 个学生数据,要求打印出最高分的学生信息以及不及格学生的信息要求:
(1)定义学生结构体。
(2)用一个函数实现N 个学生数据的输入;
(3) 用一个函数实现N个学生数据的输出;
(4) 用一个函数完成返回C语言成绩最高及最低人的信息。
(5) 在主函数中显示(4)的信息。
(6) 打印优秀及不及格同学的信息
void Main()
{
string[] fileList =new string[] {"list_1.htnl","list_10.html","list_100.html","list_111.html","list_109.html","list_11.html"};
fileList= fileList.OrderBy(s =>int.Parse( Regex.Match(s, @"\d+").Value)).ToArray();
foreach (string s in fileList)
{
Console.WriteLine(s);
}
}

/*
结果:
list_1.htnl
list_10.html
list_11.html
list_100.html
list_109.html
list_111.html

/*

字符串比较函数strcmp(字符串1,字符串2)
把字符串1和字符串2进行逐个字母比较
如果1>2返回整数
1<2返回负数
1==2返回0

直接采用冒泡排序法,比较确定字符的ascII码,就可以了。‘A