类:
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;
}
}
}
}
main:
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);
}
}
}
就是想调用类然后输出
|