1338扬辉三角

来源:互联网 发布:美国非农数据历史指数 编辑:程序博客网 时间:2024/04/29 14:07

扬辉三角

Time Limit: 1 Seconds     Memory Limit: 32768 K

Total Submit:741     Accepted:186


Description

输出扬辉三角

Input

本题有测试数据,每组数据仅含一个整数N(N不大于34)。一组数据独占一行。

Output

对于每一组数据,先输出一个

Case #:
。其中#号代表第#组数据。接下来输出一个由数字组成的扬辉三角。一行中的数字之间用一个空格分开。行尾不要有多余的空格。
两组数据之间空开一行。

Sample Input

63

 

Sample Output

Case 1:11 11 2 11 3 3 11 4 6 4 11 5 10 10 5 1Case 2:11 11 2 1

 

Source

tongji OJ

 

Source:

#include "stdio.h"int main(){    int yh[34][34];    int i,j,n,x;x=0;while(scanf("%d",&n)!=EOF){printf("Case %d:/n",++x);    for(i=0;i<n;i++)        for(j=0;j<n;j++)           {if(j==0||i==j)                yh[i][j]=1;            else            yh[i][j]=yh[i-1][j-1]+yh[i-1][j];         }    for(i=0;i<n;i++)        {for(j=0;j<i;j++)                   printf("%d ",yh[i][j]);        printf("%d",yh[i][j]);            printf("/n");         }printf("/n");}return 0;}