Алгоритм то програм 2 Самостійна робота (завдання підвищеної складності) 1 ПВиконай завдання 9і 10 у грі Блоклі «Пташка»: https://blockly-games. appspot.com/bird. Ал... А.А., Л от 10 м ортолб OTOMOD0monov
{таким образом, фразу " работа на завтра." можно закодировать как "11000100-11101110-11101100-11100000-11111000-11101101-11111111-11111111-100000-11110000-11100000-11100001-11101110-11110010-11100000-100000-11101101-11100000-100000-11100111-11100000-11100010-11110010-11110000-11100000-101110-".}
С++20
#include <iostream>#include <vector>class Point {public: int x, y; Point() = default; Point(const Point &) = default; Point(int _x, int _y) : x(_x), y(_y) {} Point operator + (const Point& p) const { return Point {x + p.x, y + p.y}; } Point operator - (const Point& p) const { return Point {x - p.x, y - p.y}; } std::vector<Point> operator & (const Point& p) const { return std::vector<Point> { Point {x + p.x, y + p.y}, Point {x - p.x, y + p.y}, Point {x + p.x, y - p.y}, Point {x - p.x, y - p.y}, Point {x + p.y, y + p.x}, Point {x - p.y, y + p.x}, Point {x + p.y, y - p.x}, Point {x - p.y, y - p.x}, }; } static Point max (const Point& p1, const Point& p2) { return Point {std::max(p1.x, p2.x), std::max(p1.y, p2.y)}; } static Point min (const Point& p1, const Point& p2) { return Point {std::min(p1.x, p2.x), std::min(p1.y, p2.y)}; } [[nodiscard]] int distance_to_by_ch (const Point & p) const { return std::max(std::abs(p.x - x), std::abs(p.y - y)); } [[nodiscard]] int distance_to_by_m (const Point & p) const { return std::abs(p.x - x) + std::abs(p.y - y); } friend std::ostream &operator << (std::ostream &os, Point const &p) { return os << "(" << p.x << ";" << p.y << ")"; } Point & operator = (const Point &) = default; bool operator == (const Point & p) const { return x == p.x && y == p.y; }};class Horse {public: const Point p; explicit Horse (const Point position) : p(position) { } [[nodiscard]] bool can_I_kill_this_guy (const Point & m) const { auto field = p & Point{2, 3}; return std::find(field.begin(), field.end(), m) != field.end(); }};std::istream &to_number(std::istream &stream) { char ch; do { ch = stream.get(); } while (!isalpha(ch)); if (isupper(ch)) ch -= 16; else ch -= 48; stream.putback(ch); return stream;}int main () { Point horse_p{}, stranger_p{}; std::cin >> horse_p.x >> to_number >> horse_p.y; std::cin >> stranger_p.x >> to_number >> stranger_p.y; Horse jack(horse_p); std::cout << "I am a Horse placed on " << jack.p << ". " << "Can I kill those guy on " << stranger_p << "? " << "-> " << std::boolalpha << jack.can_I_kill_this_guy(stranger_p); }{данная программа переводит любое сочетание символов ascii в систему счисления заданную пользователем.}
//pascal abc.net v3.0 сборка 1111
var
a,i,b,r,n,j,bug: integer;
s,se,slo,slof: string;
procedure preob(var a,b,n: integer; var se: string);
begin
repeat
b: =a mod n;
a: =a div n;
str(b,se);
s+=se;
until (a< =n-1);
end;
beginreadln(slo);
readln(n);
for j: =1 to length(slo) do
begin;
a: =ord(slo[j]);
preob(a,b,n,se);
str(a,se);
s+=se;
for i: =1 to length(s) div 2 do
begin;
se: =s[i];
s[i]: =s[length(s)-i+1];
s[length(s)-i+1]: =se[1];
end;
write(s,'-');
slof: =slof+s;
delete(s,1,length(s));
end;
end.
пример ввода:
работа на завтра.
2
пример вывода:
11000100-11101110-11101100-11100000-11111000-11101101-11111111-11111111-100000-11110000-11100000-11100001-11101110-11110010-11100000-100000-11101101-11100000-100000-11100111-11100000-11100010-11110010-11110000-11100000-101110-
{таким образом, фразу " работа на завтра." можно закодировать как "11000100-11101110-11101100-11100000-11111000-11101101-11111111-11111111-100000-11110000-11100000-11100001-11101110-11110010-11100000-100000-11101101-11100000-100000-11100111-11100000-11100010-11110010-11110000-11100000-101110-".}