TQC+ JAVA 306 迴圈次方計算
import java.util.*;
public class JPA03 {
public static void main (String argv[]) {
int num1=1, num2;
Scanner input = new Scanner(System.in);
while (num1 != 999) {
System.out.println("Input:");
num1 = input.nextInt();
num2 = input.nextInt();
if(num1==999)
break;
System.out.println(powerOf(num1, num2));
}
}
static int powerOf (int m, int n) {
int sum=m;
while(n!=1){
sum*=m;
n--;
}
return sum;
}
}
沒有留言:
張貼留言