数字三角形

include

using namespace std;
int a[21][21];
int main(){
int n, s;
cin >> n >> s;
for(int j = 1; j <= n; j++) {
for(int i = 1; i <= j; i++,s++){
a[i][j]=(s - 1)%9+1;
}
}
for(int i = 1; i <= n; i++){
for(int j= 1; j <= n; j++){
if(a[i][j]== 0){
cout << " ";//1
} else if(j == n){
cout << a[i][j];
} else {
cout << a[i][j] << " ";
}
}
cout << endl;
}
return 0;
}
//1:要有2个空格

posted @ 2025-03-23 11:37  浩瀚宇宙星晨  阅读(9)  评论(0)    收藏  举报