Problem
Output: Yang Hui triangle
Input
This topic contains multiple groups of test data, each of which contains only one integer n (n not greater than 34 ). A group of data occupies only one row.
Output
For each group of data, first output
Case #:
# Indicates the # group data. Next, output a Yang Hui triangle composed of numbers. Numbers in a row are separated by a space. Do not have any extra spaces at the end of the line.
One row is empty between the two groups of data.
Sample Input
6
3
Sample output
Case 1:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
Case 2:
1
1 1
1 2 1
---------------------
/*
This answer has been compiled and accepted through Tongji
Result memory time Language Date
Accepted 44 K 2 Ms C ++ 18:37:41
Zhouyinhui
*/
# Include <stdio. h>
# Include <malloc. h>
# Define Max 35
Int main ()
{
Int N;
Int casenum = 0;
While (scanf ("% d", & N )! = EOF)
{
Casenum ++;
If (casenum! = 1)
{
Printf ("\ n ");
}
Printf ("case % d: \ n", casenum );
Int I;
Int J;
Int arr [Max] [Max] ={{ 0 }};
For (I = 0; I <n; I ++)
{
Arr [I] [0] = 1;
}
For (I = 1; I <n; I ++)
{
For (j = 1; j <n; j ++)
{
Arr [I] [J] = arr [I-1] [J-1] + arr [I-1] [J];
}
}
For (I = 0; I <n; I ++)
{
For (j = 0; j <n; j ++)
{
If (ARR [I] [J]! = 0)
{
If (J! = I)
{
Printf ("% d", arr [I] [J]);
} Else
{
Printf ("% d", arr [I] [J]);
}
}
}
Printf ("\ n ");
}
}
Return 0;
}