社区
C#
帖子详情
请用C#编写一个冒泡排序算法,立即给分!
chinaraul
2003-08-02 10:38:33
用C#语法编写冒泡排序或是选择排序也行(得建类),率先答出者马上送分!
...全文
453
6
打赏
收藏
请用C#编写一个冒泡排序算法,立即给分!
用C#语法编写冒泡排序或是选择排序也行(得建类),率先答出者马上送分!
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
6 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
chinaraul
2003-08-02
打赏
举报
回复
班门斧,你真厉害!
baisun
2003-08-02
打赏
举报
回复
that's OK!
TheAres
2003-08-02
打赏
举报
回复
using System;
namespace SelectSorter
{
public class SelectSorter
{
public void Sort( int[] list )
{
int tmp;
for( int i = 0; i < list.Length; i++ )
{
for( int j = i + 1; j < list.Length; j++ )
{
if ( list[i] > list[j] )
{
tmp = list[i];
list[i] = list[j];
list[j] = tmp;
}
}
}
}
}
public class MainClass
{
public static void Main()
{
int[] iArrary=new int[]{1,5,13,6,10,55,99,2,87,12,34,75,33,47};
SelectSorter sh=new SelectSorter();
sh.Sort(iArrary);
for(int m=0;m<iArrary.Length;m++)
Console.Write("{0} ",iArrary[m]);
Console.WriteLine();
Console.ReadLine();
}
}
}
chinaraul
2003-08-02
打赏
举报
回复
果然酷。能否再给一个选择排序的例子。
TheAres
2003-08-02
打赏
举报
回复
using System;
namespace BubbleSorter
{
public class BubbleSorter
{
public void Sort(int [] list)
{
int i,j,temp;
bool done=false;
j=1;
while((j<list.Length)&&(!done))
{
done=true;
for(i=0;i<list.Length-j;i++)
{
if(list[i]>list[i+1])
{
done=false;
temp=list[i];
list[i]=list[i+1];
list[i+1]=temp;
}
}
j++;
}
}
}
public class MainClass
{
public static void Main()
{
int[] iArrary=new int[]{1,5,13,6,10,55,99,2,87,12,34,75,33,47};
BubbleSorter sh=new BubbleSorter();
sh.Sort(iArrary);
for(int m=0;m<iArrary.Length;m++)
Console.Write("{0} ",iArrary[m]);
Console.WriteLine();
Console.ReadLine();
}
}
}
saucer
2003-08-02
打赏
举报
回复
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=256&lngWId=10
but you should be using
Array.Sort(YourArrayObject);
Array 数据结构 源程序 更容易 方便 体现
算法
,
C#
语言
编写
Array 数据结构 源程序 更容易 方便 体现
算法
,
C#
语言
编写
c#
给学员的笔记 asp.net笔记
C#
是微软公司发布的一种面向对象的、运行于.NET Framework之上的高级程序设计语言。并定于在微软职业开发者论坛(PDC)上登台亮相。
C#
是微软公司研究员Anders Hejlsberg的最新成果。
C#
看起来与Java有着惊人的相似;它包括了诸如单一继承、接口、与Java几乎同样的语法和编译成中间代码再运行的过程。但是
C#
与Java有着明显的不同,它借鉴了Delphi的
一个
特点,与COM(组件对象模型)是直接集成的,而且它是微软公司.NET windows网络框架的主角。
2011
C#
最新总结
cts:通用类型系统 cls:公共语言规范 asp.net Internet应用程序 Write once,run anywhere! 1.注意类型转换。 2.int型与double型相运算结果为double型: int sum=10; sum*=0.5; sum为double型。 3.swich(int/char/string类型) { case 表达式: break; default: break;//跳出外层语句 }
《Hello
算法
》:动画图解、一键运行的数据结构与
算法
教程,支持 Python, C++, Java,
C#
, G.zip
《Hello
算法
》:动画图解、一键运行的数据结构与
算法
教程,支持 Python, C++, Java,
C#
, G
《Hello
算法
》:动画图解、一键运行的数据结构与
算法
教程
《Hello
算法
》:动画图解、一键运行的数据结构与
算法
教程,支持 Python, C++, Java,
C#
, Go, Swift, JS, TS, Dart, Rust, C, Zig 等语言
C#
111,094
社区成员
642,554
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章