标题: 一个让我蛋碎的技巧问题 [打印本页] 作者: yueguhua 时间: 2012-9-17 08:53 标题: 一个让我蛋碎的技巧问题 class类中:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ClassLibrary1
{
public class Class1
{
public static void diaohuan(int[] fenshu, int j)
{
if (fenshu[j] < fenshu[j + 1])
{
int temp = fenshu[j];
fenshu[j] = fenshu[j + 1];
fenshu[j + 1] = temp;
}
}
}
}
Program.cs中:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassLibrary1;
namespace ConsoleApplication9
{
class Program
{
private static int fenshu;
static void Main(string[] args)
{
Console.WriteLine("请输入班级人数");
int renshu = Convert.ToInt32(Console.ReadLine());
int[] fenshu = new int[renshu];
for (int i = 0; i < fenshu.Length; i++)
{
for (int j = 0; j < fenshu.Length - i - 1; j++)
{
Class1.diaohuan(int[] fenshu , int j);