AcWing 2877. 乘法表+JAVA
原题链接
简单
作者:
xiaozuo99
,
2021-03-23 00:01:39
,
所有人可见
,
阅读 415
import java.util.Scanner;
public class Main{
public static String get(int n,int b){
StringBuilder sb = new StringBuilder();
while(n!=0){
if(n%b >9){
sb.append((char)(n%b -10+'A'));
}else{
sb.append(n%b);
}
n/=b;
}
return sb.reverse().toString();
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
char x,y;
int b = sc.nextInt();
for(int i = 1;i<b;i++){
for(int j = 1;j<=i;j++){
if(i<10) x=(char)(i+48);
else x=(char)(i-10+ 'A') ;
if(j<10) y=(char)(j+48);
else y=(char)(j-10 + 'A');
System.out.print(x+"*"+y+"="+get(i*j,b)+" ");
}
System.out.println();
}
}
}