ответ: Только не точь в точь, а то за это бан)
#include <iostream>
#include <vector>
#include <cstdint>
using namespace std; template <class T>
istream& operator>>(istream &in, vector<T> &vec) { for (auto &it : vec) in >> it; return in;
}
template <class T>
ostream& operator<<(ostream &out, vector<T> &vec) { for (auto &it : vec) out << it << ' '; return out;
}
template <class T, class U>
istream& operator>>(istream &in, pair<T, U> &pair){
in >> pair.first >> pair.second; return in;
}
template <class T, class U>
ostream& operator<<(ostream &out, pair<T, U> &pair) { out << pair.first << ' ' << pair.second; return out;
}
signed main(void) { int32_t n; cin >> n; vector<vector<int64_t>> a(n, vector<int64_t>(n,-1));
int64_t x = 0, y = n/2;
a[x][y] = 1;
for(int32_t i = 2; i <= n*n; ++i) {
int _x = x, _y = y;
if(!x) {
x = n-1;
}else {
x-=1;
}
if(y == n-1){
y = 0;
}else {
y++;
}
if(a[x][y] != -1){
x= _x, y = _y;
while(a[x][y] != -1){
if(x == n-1){
x = 0;
}else{
x++;
}
}
}
a[x][y] = i;
}
for(int32_t i = 0; i < n; ++i){
cout << a[i] << '\n';
}
return 0;
}
У вас есть 4-ая? Я щас создам вопрос!
Если , оцени)
uses crt;
var i,count:integer;
a:array[1..8] of integer;
begin
count:=0;
randomize;
for i:=1 to 8 do a[i]:=random(19)-8;
for i:=1 to 8 do write(a[i],' ');
writeln;
for i:=1 to 8 do
begin
if a[i]<0 then inc(count);
if (a[i]<0) and (count = 5) then writeln(i);
end;
if count < 5 then writeln('empty');
readln();
end.
uses crt;
var i,count:integer;
a:array[1..8] of integer;
begin
count:=0;
randomize;
for i:=1 to 8 do a[i]:=random(19)-8;
for i:=1 to 8 do write(a[i],' ');
writeln;
for i:=1 to 8 do
begin
if a[i]<0 then inc(count);
if (a[i]<0) and (count = 5) then writeln(i);
end;
if count < 5 then writeln('empty');
readln();
end.
Заголовок окна содержит имя открытого объекта и кнопки управления окном.