递归,导致大量重复计算,但代码很短

#include <cstdio>
#include <iostream>

using namespace std;

int Yanghuinum(int row, int col){
	if(row == 0 || col == 0 || row == col){
		return 1;
	}else{
		return Yanghuinum(row-1, col-1) + Yanghuinum(row-1,col);
	}
}//显而易见,代码简单,但是会做很多重复计算,无所谓了

int main(){
	int n;
	while(scanf("%d",&n) != EOF){
		for(int i=0; i<n; i++){
			for(int j=0; j<=i; j++){//<=是个细节 
				printf("%5d",Yanghuinum(i,j));
			}
			printf("\n");
		}
	}
	return 0;
}