Daily practice 45

  1. Use programming to calculate and output the first n lines of Yang Hui's triangle (requires n to be input from the keyboard) output the first n lines of Yang Hui's triangle (a space between each number in each line, and the last number in each line does not require a space
    #include "stdio.h "
    Void main()
    { int a[100][100]; int i,j,n; scanf("Please input N:\n): for(i=0;i<n;i++) a[i][ 0]=1; for(i=0;i<n;i++) a[i][i]=1; for(i=2;i<n;i++) for(j=1;j<=i; j++) a[i][j]=a[i-1][j-1]+a[i-1][j]; printf(“the result is :\n”); for(i=0; i<n;i++) { for(j=0;j<=i;j++) printf("%5d",a[i][j]); printf("\n"); } }

















Guess you like

Origin blog.csdn.net/drake_gagaga/article/details/113925841