ZZULIOJ-1005,整数幂(Java)

mac2026-05-19  6

题目描述:

输入3个整数,输出它们的1次幂、2次幂和3次幂。 

输入: 

输入3整数,用空格隔开。  

输出: 

输出3行,每行3个整数,分别是它们的1次幂、2次幂和3次幂,每个整数占9列,不足9列左对齐。 

样例输入: 

1 5 100 

样例输出: 

1 1 1

5 25 125

100 10000 1000000 

 程序代码:

import java.util.*; public class Main { public static void main(String[] args) { Scanner input=new Scanner(System.in); int a=input.nextInt(); int b=input.nextInt(); int c=input.nextInt(); System.out.printf("%-9d%-9d%-9d\n",a,a*a,a*a*a); System.out.printf("%-9d%-9d%-9d\n",b,b*b,b*b*b); System.out.printf("%-9d%-9d%-9d\n",c,c*c,c*c*c); } }

 

最新回复(0)