标签:can ann get 打印 long [] str java next
import java.util.Scanner;
class Test4{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("请输入杨辉三角形的行数:");
int line = input.nextInt();
for(int i = 1; i<=line; i++){
for(int j=line-i; j>0; j--){
System.out.print(" ");
}
for(int k=1; k<=i; k++){
long n=getNum(i-1), r=getNum(k-1), m=getNum(i-k);
System.out.print(" "+(n/r/m));
}
System.out.println();
}
}
public static long getNum(long num){
if(num==0||num==1){
return 1;
}else{
return num*getNum(num-1);
}
}
}
标签:can ann get 打印 long [] str java next
原文地址:https://www.cnblogs.com/xuxiao-1987/p/10068242.html