Cod sursa(job #2253881)
| Utilizator | Data | 4 octombrie 2018 15:21:30 | |
|---|---|---|---|
| Problema | Tablete | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin ("tablete.in");
ofstream fout ("tablete.out");
int n, k, i, j, x, r;
int main (){
fin >> n >> k;
x = 1;
for (i = 1; i <= n; ++i) {
for (j = 1; j <= n; ++j) {
if (j == 1 && r != 0) {
fout << r << ' ';
continue;
} else {
if (j == k) {
if (x % 2 == 0) {
fout << x << ' ';
} else {
fout << x + 1 << ' ';
r = x++;
}
} else {
fout << x << ' ';
}
x++;
}
}
fout << "\n";
}
}
