[c#]代码库
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.Write("输入整数幂的次数: n = ");
int n = int.Parse(Console.ReadLine());
MyApp(n);
Console.ReadLine();
}
/// <summary>
/// n位整数的每一位数字的n次幂之和与原数相等
/// </summary>
/// <param name="n">整数的位数(2<n<9)</param>
public static void MyApp(int n)
{
int i,l = 1, m = 10;
for(i=0;i<n-1;i++)
{
l *= 10;
m *= 10;
}
int a, b, c, d, j;
for(i=l;i<m;i++)
{
a = i;
d = 0;
while (a > 0)
{
b = a % 10;
j = n;
c = 1;
while (j-- > 0)
c *= b;
d += c;
a /= 10;
}
if (d == i)
Console.WriteLine("{0,12}", i);
}
}
}
}