Pagini recente » Cod sursa (job #2315620) | Cod sursa (job #3000976) | Cod sursa (job #2847565) | Cod sursa (job #338674) | Cod sursa (job #2253878)
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin ("tablete.in");
ofstream fout ("tablete.out");
int n, k, i, j, x, r;
int main (){
cin >> n >> k;
x = 1;
for (i = 1; i <= n; ++i) {
for (j = 1; j <= n; ++j) {
if (j == 1 && r != 0) {
cout << r << ' ';
continue;
} else {
if (j == k) {
if (x % 2 == 0) {
cout << x << ' ';
} else {
cout << x + 1 << ' ';
r = x++;
}
} else {
cout << x << ' ';
}
x++;
}
}
cout << "\n";
}
}