U E D R , A S I H C RSS

파스칼삼각형/문원명

파스칼,.

~cpp 
#include <iostream>
using namespace std;

int pas(int aCol, int aRow);

void main()
{
	int row, col, res;
	cout<<"행과 열을 입력 : ";
	cin >> row >> col;
	res = pas(col, row);
	cout << res << endl;
}

int pas(int aCol, int aRow)
{
	if(aCol == 1 || aCol == aRow)
		return 1;
	else 
		return pas(aCol - 1, aRow - 1) + pas(aRow,  aCol - 1);
}

댓글

  • 3행 2열은 값이 안나오는데요?... -지훈
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:31:23
Processing time 0.0101 sec