Common C language Face question seven: Yang Hui's triangle

Source: Internet
Author: User
  Int _tmain (int argc, _tchar* argv[]) {    int i,j,a[10][10];      //i represents Row, J represents column     for (i=0;i<10;i++)        //first assign values to 0         for (j=0;j<10;j++)            a[i][j]=0;     for (i=0;i<10;i++)       //assigns no row to the tail of 1      {      a[i][0]=1;       a[i][i]=1;     }         //starts with the second line except the last number and the first number,   // Each number is the same column as the previous row of its line with the previous column and   for (i=2;i<10;i++)               for (j=1;j<i;j++)       a[i][j]=a[i-1][j-1]+a[i-1][j];         printf ("**************/n");   for (i=0;i<10;i++)   {    for (j=0;j<i+1;j++)         //j<i+1 because there is no row, the column is the current number of rows +1, as in line 4th there are 5 columns       printf ("%5d", a[i][j);     printf ("n");   }       return 0; }//0:  1//1:  1  1//2:  1  2  1//3:  1   3  3  1//4:  1  4  6  4  1// 5:  1  5  10 10 5  1//...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.