打印杨辉三角
打印杨辉三角形(行数可以键盘录入) 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 import java . util . Scanner ; public class duoweishuzu1 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int m = scanner . nextInt ( ) ; int arr [ ] [ ] = new int [ m ] [ m ] ; for ( int i = 0 ; i < arr . length ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) { arr [ i ] [ 0 ] = 1 ; arr [ i ] [ i ] = 1 ; if ( i >= 2 && j >= 1 && j < i ) { arr [ i ] [ j ] = arr [ i - 1 ] [ j ] + arr [ i - 1 ] [ j - 1 ] ; } System . out . print ( arr [ i ] [ j ] + "\t" ) ; } System . out . println ( "\t" )