855 - EECS_I2P(I)2015_Chen_Lab5 Scoreboard

Time

2015/11/04 08:30:00 2015/11/04 10:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10800 Pascal's triangle

10800 - Pascal's triangle   

Description

As described in Wikipedia, Pascal's triangle is a triangular array of the binomial coefficients. The element k on row n of Pascal’s triangle can be calculated by the following relation:
C(n, 1) = 1, for n = 1, 2, …
C(n, n) = 1, for n = 1, 2, …
C(n, k) = C(n-1, k-1) + C(n-1, k),  for k = 2, 3, … and for n = 2, 3, …

Given a nonnegative integer M, display the Pascal’s triangle from row 1 to row M.
Print some space so that the output graph is that we know the Pascal's triangle .Use '%6d' to print each element. Print a newline ' ' at the end of each row.

Input

A positive integer M (1<=M<=10)

Output

Print some space so that the output graph is that we know the Pascal's triangle and use %6d to print each element.

Sample Input  Download

Sample Output  Download

Tags




Discuss