让对角线的元素为k就行
#include <iostream>
using namespace std; int main() {
int n,k;
cin >> n >> k;
for(int i = ; i < n; ++ i){
for(int j = ; j < n ; ++ j){
if(j != ) cout<<" ";
if( i == j) cout<<k;
else cout<<;
}
cout<<endl;
}
return ;
}
2021-07-26 15:51:55
让对角线的元素为k就行
#include <iostream>
using namespace std; int main() {
int n,k;
cin >> n >> k;
for(int i = ; i < n; ++ i){
for(int j = ; j < n ; ++ j){
if(j != ) cout<<" ";
if( i == j) cout<<k;
else cout<<;
}
cout<<endl;
}
return ;
}