Code
using System;
using System.Collections.Generic;
using System.Text;
namespace ExArrange
{
class Arrange
{
public static int asdf=0;//我加的,记录个数用的
public void Arrange1(int n, int r)
{
int i = 0, j;
string s;
int[] a = new int[n];
a[i] = 1;
while (true)
{
if ((a[i] - i) <= (n - r + 1))
{
if (i == (r - 1))
{
s = "";
for (j = 0; j < r; j++)
{
s = s + Convert.ToString(a[j]) + ",";
}
// Memo1.Lines.Append(Trim(s));
Console.WriteLine(s);asdf++;
a[i] = a[i] + 1;
continue;
}
i = i + 1;
a[i] = a[i - 1] + 1;
}
else
{
if (i == 0)
{
break;
}
i = i - 1;
a[i] = a[i] + 1;
}
}
}
static void Main(string[] args)
{
Arrange e = new Arrange();
e.Arrange1(6, 3);
Console.WriteLine("一共:"+asdf);
Console.ReadLine();
}
}
}
posted @
2009-01-12 18:59
jianlinglo
阅读(
588)
评论()
编辑
收藏
举报