楼上的循环不行啊~你试试输入3,2,1~起码双循环的~~~我这个是从小到大输出
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] a = new int[3];
for (int i = 0; i < a.Length; i++)
a[i] = Int32.Parse(Console.ReadLine());
Array.Sort(a);
foreach (int t in a)
Console.Write(t + " ");
}
}
}
我这个随便输入几数的,从小到大排.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication29
{
class Program
{
static void Main(string[] args)
{
Console.Write("输入数:");
string[] s = Console.ReadLine().Split();
int len = s.Length;
int[] Int = new int[len];
for (int i = 0; i < s.Length; i++)
{
Int[i] = Convert.ToInt32(s[i]);
}
Array.Sort(Int);
foreach (int t in Int)
{
Console.Write(t + " ");
}
Console.ReadLine();
}
}
}
static void Main(string[] args)
{
int[] a = new int[3];
for (int i = 0; i < a.Length; i++)
a[i] = Int32.Parse(Console.ReadLine());
for (int i = 0; i < a.Length - 1; i++)
{
if (a[i] < a[i + 1])
{
int temp = a[i];
a[i] = a[i + 1];
a[i + 1] = temp;
}
}
foreach (int t in a)
Console.Write(t + " ");
}
从大到小输出
话说你说的调用两个类是什么意思?
啊