不讲究时间复杂度的话,程序如下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
int _sum = 0;
for (int _tmpi = 1; _tmpi < 5; _tmpi++)
{
for (int _tmpj = 1; _tmpj < 5; _tmpj++)
{
for (int _tmpk = 1; _tmpk < 5; _tmpk++)
{
if ((_tmpi == _tmpj) && (_tmpj == _tmpk) && (_tmpi == _tmpk))
{
continue;
}
else
{
int tem = _tmpi * 100 + _tmpj * 10 + _tmpk;
_sum++;
Console.WriteLine(tem.ToString());
}
}
}
}
Console.WriteLine(_sum.ToString());
Console.ReadLine();
}
}
}
共60个