题解 | #字符串排序#
字符串排序
https://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace ConsoleApp4
{
class Program
{
static void Main(string[] args)
{
int x=Convert.ToInt32(Console.ReadLine());
List<string>list=new List<string>();
for(int i=0;i<x;i++)
{
list.Add(Console.ReadLine());
}
list.Sort(string.CompareOrdinal);//按照ASC码排序
for(int i=0;i<x;i++)
{
Console.WriteLine(list.ElementAt(i));
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace ConsoleApp4
{
class Program
{
static void Main(string[] args)
{
int x=Convert.ToInt32(Console.ReadLine());
List<string>list=new List<string>();
for(int i=0;i<x;i++)
{
list.Add(Console.ReadLine());
}
list.Sort(string.CompareOrdinal);//按照ASC码排序
for(int i=0;i<x;i++)
{
Console.WriteLine(list.ElementAt(i));
}
}
}
}