請撰寫程式,宣告一個變數i,如果i的值小於31,就顯示2的i次方的值。

import java.io.*;

public class ex4_1{
public static void main(String[] argv)
throws IOException{
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
System.out.println("→");
String i = b.readLine();
int y = Integer.parseInt(i);
if(y <=30){
long j = 1;
for(int x = 0;xj = j * 2;
}
System.out.println(j);
}
else {
System.out.println("超出數值,請重新輸入");
}
}
}
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 steven70101 的頭像
    steven70101

    老人家的舊書房

    steven70101 發表在 痞客邦 留言(1) 人氣()