编程论坛
注册
登录
编程论坛
→
ASP.NET技术论坛
C# 的一些用法是怎样的
xtaywfnh
发布于 2010-09-13 15:51, 678 次点击
用C#怎样将三个数从小到大排列,,,,只要编写的格式,,,还有他的结果输出语句怎样写
3 回复
#2
Ben_faster
2010-09-14 17:34
方法有很多, 直接的放在一个数组里面,设置一个临时值去比较,排序!
#3
Wita
2010-09-15 09:27
if a>b then
if b>c then
response.write c
else
response.write b
elseif a>c then
response.write c
else
response.write a
end if
#4
Issac_abc
2010-09-17 14:42
int[] a = new int[3]; //用数组存数
for (int i = 0; i < a.Length; i++)
{
Console.WriteLine("输入第{0}个数字", i + 1);
a[i] = Int32.Parse(Console.ReadLine());
}
//比较后在排序
for (int i = 0; i < a.Length-1; i++)
{
if (a[i] > a[i + 1])
{
int tp = a[i];
a[i] = a[i + 1];
a[i + 1] = tp;
}
}
//然后输出结果
for (int i = 0; i < a.Length; i++)
{
Console.Write(a[i] + " ");
}
1