AcWing 2877. Java简单明了
原题链接
简单
作者:
还想听你的故事
,
2021-04-13 15:36:49
,
所有人可见
,
阅读 351
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
for(int i=1;i<n;i++){
for(int j=1;j<=i;j++){
System.out.printf("%s*%s=%s ",base(i,n),base(j,n),base(i*j,n));
}
System.out.println();
}
}
private static String base(int x,int b){
StringBuilder sb=new StringBuilder();
while(x!=0){
sb.append(get(x%b));
x/=b;
}
return sb.reverse().toString();
}
private static char get(int x){
if(x<10) return (char)(x+'0');
else return (char)(x-10+'A');
}
}