No older revisions available
No older revisions available
파스칼삼각형 배열 이용
~cpp #include <iostream> using namespace std; const int MAX = 100; int main() { int arr[MAX][MAX]; for (int i=1; i<MAX; i++) { arr[i][1] = 1; arr[i][i] = 1; } int j,k; for (j=2; j<MAX; j++) { for (k=1; k<MAX; k++) { if (j+1 == k+1) break; arr[j+1][k+1] = arr[j][k] + arr[j][k+1]; } } int row,col; cout << "행과 열을 입력: "; cin >> row >> col; cout << arr[row][col] << endl; return 0; }