#include <iostream> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; if(k < max(m, n)) { cout << -1 << endl; return 0; } int res = k - max(m, n) + 1; for(int i = 0; i < n; ++i) { for(int j = 0; j < m; ++j) { if(i == j) { if(i == 0) cout << res; else cout << 1; } else { if(n > m && i >= m && j == m-1) cout << 1; else if(n < m && i == n-1 && j >= n) cout << 1; else cout << 0; } cout << " "; } cout << endl; } return 0; }
让第一个输出多余的其他格子对角线优先考虑1,其次为0,,然后顺序输出就行了。