标签:hdu
2 3
1 1 1 1 1 1 1 2 1
#include <iostream> using namespace std; int main() { int a[40][40]; int c[40][40]; int n; for (int i=0; i<40; i++) { for (int j=0; j<40; j++) { if (i==j) c[i][j]=1; c[i][0]=1; } } while (cin >> n) { if (n==1) cout << 1<<endl; else if (n==2) { cout << 1<< endl; cout << 1<< " " << 1 << endl; } else { for (int i=2; i<n; i++) { for (int j=1; j<i; j++) c[i][j]= c[i-1][j]+c[i-1][j-1]; } for (int i=0; i<n; i++) { for (int j=0; j<i; j++) { cout << c[i][j] << " "; } cout << c[i][i]; cout <<endl; } } cout << endl; } return 0; }
标签:hdu
原文地址:http://blog.csdn.net/xiaotan1314/article/details/46333763