標題:
306-迴圈次方計算
[打印本頁]
作者:
許承鴻
時間:
2018-7-17 18:26
標題:
306-迴圈次方計算
import java.util.*;
public class JPD03 {
public static void main (String argv[]) throws IOException {
int num1, num2;
Scanner input = new Scanner(System.in));
System.out.println("Input:");
num1 = input.nextInt();
while (num1 != 999) {
num2 = input.nextInt();
System.out.println(powerOf(num1, num2));
...
}
}
static int powerOf (int m, int n) {
...
}
}
作者:
巫沛庭
時間:
2018-7-17 19:39
本帖最後由 巫沛庭 於 2018-7-17 19:43 編輯
import java.util.*;
public class JPA03 {
public static void main (String argv[]){
int num1, num2;
Scanner input = new Scanner(System.in);
System.out.println("Input:");
num1 = input.nextInt();
while (num1 != 999) {
num2 = input.nextInt();
System.out.println(powerOf(num1, num2));
num1 = input.nextInt();
}
}
static int powerOf (int m, int n) {
int g=1;
while(n>0)
{
g*=m;
n--;
}
return g;
}
}
複製代碼
作者:
張閎鈞
時間:
2018-7-17 19:41
package hi87;
import java.util.Scanner;
public class hi78 {
static Scanner keyboard = new Scanner(System.in);
public static void main (String argv[]){
int num1, num2;
Scanner input = new Scanner(System.in);
System.out.println("Input:");
num1 = input.nextInt();
while (num1 != 999) {
num2 = input.nextInt();
System.out.println(powerOf(num1, num2));
num2 = input.nextInt();
}
}
static int powerOf(int m, int n) {
int g=1;
while(n>0)
{
g*=m;
n--;
}
return g;
}
}
複製代碼
作者:
巫晉宇
時間:
2018-7-17 19:53
public class rrrrr {
static Scanner e = new Scanner(System.in);
public static void main(String[] args) {
// TODO 自動產生的方法 Stub
test();
test();
test();
test();
}
private static void test() {
// TODO 自動產生的方法 Stub
int p = 1;
System.out.println("Input:");
int o=e.nextInt();
while( o!=999)
{
int w=e.nextInt();
System.out.println(powerOf (o, w));
o = e.nextInt();
}
}
static int powerOf (int m,int n) {
int g=1;
while(n>0)
{
g=g*m;
n--;
}
return g;
}
}
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2