package vvkg;
import java.util.Scanner;
public class A1{
public static void main(String[] args) {
Scanner A=new Scanner(System.in);
System.out.print("请输入第一个数x:");
double x=A.nextDouble();
System.out.print("请输入第二个数n:");
int n = A.nextInt();
double j =Math.pow(x,n);
System.out.print("x^n:"+j);
}
public static double factor(int n, double x){
if(n==0)
return 1;
else
return factor(n-1,x)*x;
}
}
运行结果:
请输入第一个数x:4
请输入第二个数n:2
x^n:16.0
Process finished with exit code 0