Collection -> Array的排序(正序/逆序)
2007-12-14 11:47
555 查看
2005年10月07日 21:40:00
using System;
namespace Array操作
{
/// >summary<
/// Class1 的摘要说明。
/// >/summary<
class Class1
{
/// >summary<
/// 应用程序的主入口点。
/// >/summary<
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
String[] friends=new String[]{"2mojian","1zhengjian","3xugang","4guoyonghui"};
Console.WriteLine("操作前数组数据为:");
foreach(string index in friends)
{
Console.Write(index+" ");
}
Array.Sort(friends);
Console.WriteLine("/n排序后的数据为:");
for(int i=friends.GetLowerBound(0);i>=friends.GetUpperBound(0);i++)
{
Console.Write(friends[i]+" ");
}
Array.Reverse(friends);
Console.WriteLine("/n逆序后的数据为:");
for(int i=friends.GetLowerBound(0);i>=friends.GetUpperBound(0);i++)
{
Console.Write(friends[i]+" ");
}
Console.WriteLine();
Console.Read();
}
}
}
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=496720
using System;
namespace Array操作
{
/// >summary<
/// Class1 的摘要说明。
/// >/summary<
class Class1
{
/// >summary<
/// 应用程序的主入口点。
/// >/summary<
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
String[] friends=new String[]{"2mojian","1zhengjian","3xugang","4guoyonghui"};
Console.WriteLine("操作前数组数据为:");
foreach(string index in friends)
{
Console.Write(index+" ");
}
Array.Sort(friends);
Console.WriteLine("/n排序后的数据为:");
for(int i=friends.GetLowerBound(0);i>=friends.GetUpperBound(0);i++)
{
Console.Write(friends[i]+" ");
}
Array.Reverse(friends);
Console.WriteLine("/n逆序后的数据为:");
for(int i=friends.GetLowerBound(0);i>=friends.GetUpperBound(0);i++)
{
Console.Write(friends[i]+" ");
}
Console.WriteLine();
Console.Read();
}
}
}
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=496720
相关文章推荐
- Collection -> Array的排序(正序/逆序)
- Collection -> Array的排序(正序/逆序)
- Collection -> Array的排序(正序/逆序)
- Collection -> 用SortedList实现排序
- Collection -> 用SortedList实现排序
- Ext.util.MixedCollection-->排序,克隆,过滤
- Collection -> 用SortedList实现排序
- List<T>进行多字段排序
- List<Object>使用Object的某个属性进行排序(正序,倒序)
- 多关键字排序(里面有关于操作符(<<运算符 和 >>运算符 )的重载)
- List<T> 根据某个字段排序
- 在hibernate中 以Collection<Entity> 替换Map<Key, List<Value>结构
- 性能优化:使用SparseArray代替HashMap<Integer,Object>
- 【学习ios之路:Objective-C错误】Collection <__NSArrayM: 0xb550c30> was mutated while being enumerated.
- 数据结构:归并排序 && 逆序对统计
- wpf list<T>与ObservableCollection<T>的区别
- ListView的Adapter使用 之 初学ArrayAdapter<String>
- 解决 Crash:Collection <__NSArrayM: 0x61000024df50> was mutated while being enumerated
- <笔试><面试>编写一个排序函数,实现,既可以排序整形数组,又可以排序字符串。
- 对android常用数据集合List<Map<String,String>排序