Home > Back-end >  [C] Yang hui triangle
[C] Yang hui triangle

Time:01-27

 # include 
Int main ()
{
int i,j;
An int array [10] [10].
for(i=0; i<10; I++)
{
Array [I] [I]=1;
Array [I] [0]=1;
}

For (I=2; i<10; I++)
{
For (j=1; J<=I - 1; J++)
{
Array [I] [j]=array [j] + [I - 1] array [1] [I - 1].
}
}
for(i=0; i<10; I++)
{
for(j=0; J<=I; J++)
{
Printf (" % d "6, array [I] [j]);
}
printf("\n");
}
return 0;
}

#include
Int main ()
{
int i,j;
An int array [10] [10].
for(i=0; i<10; I++)
{
Array [I] [I]=1;
Array [I] [0]=1;
}

For (I=2; i<10; I++)
{
For (j=1; J<=I - 1; J++)
{
Array [I] [j]=array [j] + [I - 1] array [1] [I - 1].
}
}
for(i=0; i<10; I++)
{
for(j=0; J<=I; J++)
{
Printf (" % d "6, array [I] [j]);
}
printf("\n");
}
return 0;
}

CodePudding user response:

 # include & lt; stdio.h> 
# define MAXN 10
Unsigned __int64 y [MAXN] [MAXN];
int i,j;
Char s [60];
Void main () {
Printf (" % s \ n 30 ", "1");
Printf (" % s \ n 33 ", "1 1");
Ui64 y [1] [0]=1; Ui64 y [1] [1]=1;
For (I=2; iY ui64 [I] [0]=1; Sprintf (s, "1");
For (j=1; J<=I - 1; J++) {
[I] [j] y=y [I - 1] [1] + [j] [I - 1] y;
Sprintf (s, "% s % 3 i64u", s, y [I] [j]);
}
[I] [I] y=1 ui64; 1 sprintf (s, "% s", s);
* printf (" % s \ n ", 30 + I * 3, s);
}
}
//1
//1 1
//1 2 1
//1 3 3 1
//1 4 6 4 1
//5 10 10 1
//1 6 15 20 15 1
//1 July 21 35 35 21 July 1
//1 August 28 56, 70, 56, 28 August 1
//1 9 36 84 126 126 84 36 9 1

//according to the following format to print the first MAXN lines of Yang hui triangle, 
//1
//1 1
//1 2 1
//1 3 3 1
//1 4 6 4 1
//5 10 10 1
#include
# define MAXN 68
Unsigned __int64 y [MAXN] [MAXN];
int i,j;
Void main () {
Printf (" 1 \ n ");
Printf (" 1 1 \ n ");
Ui64 y [1] [0]=1; Ui64 y [1] [1]=1;
For (I=2; iY ui64 [I] [0]=1; Printf (" 1 ");
For (j=1; J<=I - 1; J++) {
[I] [j] y=y [I - 1] [1] + [j] [I - 1] y;
Printf (" % I64u ", y [I] [j]);
}
[I] [I] y=1 ui64; Printf (" 1 \ n ");
}
}
//1
//1 1
//1 2 1
//1 3 3 1
//1 4 6 4 1
//5 10 10 1
//1 6 15 20 15 1
//1 July 21 35 35 21 July 1
//1 August 28 56, 70, 56, 28 August 1
//1 9 36 84 126 126 84 36 9 1
//...
//1 67 2211 47905 766480 9657648 99795696 869648208 6522361560 42757703560 247994680648 1285063345176 5996962277488 25371763481680 97862516286480 345780890878896 1123787895356412 3371363686069236 9364899127970100 24151581961607100 57963796707857040 129728497393775280 271250494550621040 530707489338171600 972963730453314600 1673497616379701112 2703342303382594104 4105075349580976232 5864393356544251760 7886597962249166160 9989690752182277136 11923179284862717872 13413576695470557606 14226520737620288370 14226520737620288370 13413576695470557606 11923179284862717872 9989690752182277136 7886597962249166160 5864393356544251760 4105075349580976232 2703342303382594104 1673497616379701112 972963730453314600 530707489338171600 271250494550621040 129728497393775280 57963796707857040 24151581961607100 9364899127970100 3371363686069236 1123787895356412 345780890878896 97862516286480 25371763481680 5996962277488 1285063345176 247994680648 42757703560 6522361560 869648208 99795696 9657648 766480 47905 2211 67 1
  • Related