实现一个数的N次方

来源:互联网 发布:java pkcs8格式的私钥 编辑:程序博客网 时间:2024/06/01 09:23
using System;
class My
{
static void Main()
{
int a,b=1;
int n;
Console.WriteLine("请输入所要求这个数的次方数:");
n=int.Parse(Console.ReadLine());//n是次方
Console.WriteLine("请输入所要计算的这个数:");
a=int.Parse(Console.ReadLine());//a是那个数
for(int i=1;i<=n;i++)
{
b=b*a;
}
Console.WriteLine(a+"的"+n+"次方是:"+b);
}
}
0 0