样例过不去
查看原帖
样例过不去
715774
Little_Andyyu楼主2022/8/22 20:59
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k;//行数 
	cin>>k;//输入行数 
	int c[21][21]={c[1][1]=1,c[2][1]=1,c[2][2]=1};//预定义 
	int i,j; 
	for(i=3;i<=k;i++){
		c[i][1]=1;
		for(j=2;j<=k-1;j++){
			c[i][j]=c[i-1][j-1]+c[i-1][j];
		c[i][j]=1;}
	}
	for(i=1;i<=k;i++){
		for(j=1;j<=i;j++){
			if(j==i){
				cout<<c[i][j]<<endl;
			}else{
				cout<<c[i][j]<<' ';
			}
		}
	}
	return 0;
}
2022/8/22 20:59
加载中...