How to generate a triangle with C like Yang Hui?

Updated on educate 2024-02-27
6 answers
  1. Anonymous users2024-02-06

    #include

    void main()

    int n =5;Dimensionality

    int a[80] = ;

    int b[80] = ;

    int i, j;

    b[1]=1;

    for (i = 1; i <= n; i++)for (j = 1; j <= i; j++)a[j] = b[j] +b[j-1];

    for (j = 1; j <= i;j++) * copy the current line a to b for downlink *

    b[j] = a[j];

    printf("%-6d", b[j]);

    printf("");

  2. Anonymous users2024-02-05

    1. Right triangle Yang Hui triangle:

    #include

    #define m 10

    void main()

    int a[m][m], i , j ;

    for(i=0;ifor(j=0;j<=i;j++)if(i==j||j==0)

    a[i][j]=1;

    elsea[i][j]=a[i-1][j]+a[i-1][j-1];

    printf("%d",a[i][j]);

    if(i==j)printf("");

    2. Pyramid-shaped Yang Hui Triangle:

    #include

    void main()

    int a,i,j;

    for(i=0;i<10;i++)

    for(j=10;j>=i;j--)

    printf("%2c",' ');*two spaces* for(j=0; j<=i;j++)

    if(i==j||j==0)

    a[i][j]=1;

    elsea[i][j]=a[i-1][j]+a[i-1][j-1];

    printf("%3d ",a[i][j]);*%3d*

    if(i==j)

    printf("");

    1. Output Style:

    Second, Yang Hui triangle introduction:

    1. Yang Hui triangle, also known as Jia Xian triangle and Pascal triangle, is a geometric arrangement of binomial coefficients in a triangle.

    2. The Yang Hui triangle also corresponds to the coefficients of the binomial theorem.

    3. To put it simply, it is the coefficient problem after the power operation of the sum of two unknowns, such as (x+y) =x +2xy+y, so that the coefficient is , which is one of the rows, cubes, and quadratic of Yang Hui triangle, and the result of the operation depends on the coefficients of each item.

  3. Anonymous users2024-02-04

    This should work, you're modifying it yourself, and I've set the number of lines to public static void main(string args).

    for (int i = 0; i < 7; i++)for (int k = 0; k <= i; k++)

  4. Anonymous users2024-02-03

    If you can write in C, this is the same.

  5. Anonymous users2024-02-02

    Isn't it just printing an odd number of stars?

    Print 2n-1 per line.

  6. Anonymous users2024-02-01

    includeint main() } This section is put outside to output int k,l; for(k=0;k<5;++k)/////////////// ///////////////// return 0;}

Related questions
13 answers2024-02-27

The corresponding angles of congruent triangles are equal. >>>More

16 answers2024-02-27

The specific operation steps of the dumplings are as follows: >>>More

11 answers2024-02-27

∠f=360°-∠fga-∠fha-∠gah=360°-(180°-∠d-∠deg)-(180°-∠b-∠hcb)-(d+∠deh)=∠d+∠deg+∠b+∠hcb-∠d-∠deh=∠b-∠deg+∠hcb >>>More

6 answers2024-02-27

From the known, according to the cosine theorem, we know that a=30°,(1):b=60°(2):s=1 4bc, and from the mean inequality we get bc<9 4, so the maximum value is 9 16

15 answers2024-02-27

When the sum of the three sides of the triangle is greater than the third side, the triangle is obtuse and acute. When the sum of the three sides of a triangle satisfies the sum of the squares of the two right-angled sides equals the square of the third side, the triangle is a right-angled triangle.