Program project1; uses crt,math; var s:real; i,j,f:real; a:integer; begin writeln('vvedite 1 chislo ');readln(i); writeln('vvedite 2 chislo ');readln(j); writeln('vvedite 3 chislo ');readln(f); s:=i; if j<s then s:=j; if f<s then s:=f; if s<0 then begin if i<0 then inc(a); if j<0 then inc(a); if f<0 then inc(a); writeln('kolichestvo otricatelnix ',a:2); end else begin if i>0 then i:=i*-1; if j>0 then j:=i*-1; if f>0 then f:=i*-1; end; writeln('min chislo ',s:2:0); readln; end.
#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; } 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; }
Объяснение:
Запишем на C++ то, что написано в условии.
Если надо, то код также прикрепил в виде файла
Списывать не хорошо)
Если повезёт увидемся в (СИРИУС)