2018/12/04 PAT刷题 L1-012 计算指数 java
这题很简单, 就是for循环的事:
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int num = Integer.parseInt(br.readLine()); int sum = 1; for (int i=0; i<num; i++) { sum*=2; } System.out.println("2^"+num+" = "+sum); } }