Войти
Регистрация
Спроси ai-bota
В
Все
М
Математика
А
Английский язык
Х
Химия
Э
Экономика
П
Право
И
Информатика
У
Українська мова
Қ
Қазақ тiлi
О
ОБЖ
Н
Немецкий язык
Б
Беларуская мова
У
Українська література
М
Музыка
П
Психология
А
Алгебра
Л
Литература
Б
Биология
М
МХК
О
Окружающий мир
О
Обществознание
И
История
Г
Геометрия
Ф
Французский язык
Ф
Физика
Д
Другие предметы
Р
Русский язык
Г
География
Показать больше
Показать меньше
cross666
07.09.2022 15:01 •
Информатика
1. Сколько позиций в строке используется для записи операторов (исходных данных)?
2. Как записываются числовые значения данных в строке?
Показать ответ
Ответ:
kurilen
17.06.2021 09:05
С++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); }
0,0
(0 оценок)
Ответ:
Асуна19
23.12.2022 21:56
Как-то так
#include <iostream>
using namespace std;
int main(){ cout << "Vvedute kol-vo ocenok" << endl;
int n,i,a,Four,Five; n = i = a = Four = Five = 0;
cin >> n;
for (i = 1; i <= n; i++) { cin >> a; if (a == 4){ Four++;} else if (a == 5) { Five++; } } if (Four > Five){ cout << "Four" << endl;} else if (Five > Four) { cout << "Five" << endl; } else { cout << "Equal"<< endl; } cout << "Kol-vo 4: " << Four << " Kol-vo 5: " << Five << endl; return 0;}
0,0
(0 оценок)
Популярные вопросы: Информатика
nikanor020499
01.01.2020 06:46
Наиболее точным аналогом реляционной базы данных может служить...
elay0205
12.05.2023 22:49
Написать программу в pascal: по возрасту, введённому с клавиатуры, определить, к какой возрастной группе относится человек: от 0 до 7 лет дошкольник, от 8 до 17 лет школьник,...
Darishka22
25.05.2023 15:11
Что згодні ви з твердженням, що Тарас Шевченко - Націоналтний пророк ? Аргументуйте свою відповідь...
ekaterinaf79
23.05.2023 11:01
Заранее извините , что перевернуто...
KuDiAnA2003
26.11.2020 11:16
Укажите одного исторического деятеля города Истры...
DoraDreamer
18.06.2022 16:34
У автомобиля закончился бензин. Водитель автомобиля, прилагая силу величиной 84Н, толкает его до бензоколонки, находящейся на расстоянии 190 м. Какую работу проделает водитель,...
Taylis69
13.07.2022 14:33
Какой секрет вёз Левша государю? Почему это представлялось ему важным?...
Rroshok
01.04.2020 18:44
Позначте на координатній площині точки А (5; 4), В (3; 3), С (1; 0), D (7; 3), E (-2; 5), F (-2 ; -2). Побудуйте прямі АС, ВD, EF. Знайдіть координати точок, у яких ці...
VaLeRiA102030405060
01.04.2020 18:44
Ребят, очень Задачки по теории вероятности !!...
пацанизшараги
14.01.2020 02:34
(a−2/a+2 - a+2/a−2) / (12a^2/ 4-a^2)...
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota
Оформи подписку
О НАС
О нас
Блог
Карьера
Условия пользования
Авторское право
Политика конфиденциальности
Политика использования файлов cookie
Предпочтения cookie-файлов
СООБЩЕСТВО
Сообщество
Для школ
Родителям
Кодекс чести
Правила сообщества
Insights
Стань помощником
ПОМОЩЬ
Зарегистрируйся
Центр помощи
Центр безопасности
Договор о конфиденциальности полученной информации
App
Начни делиться знаниями
Вход
Регистрация
Что ты хочешь узнать?
Спроси ai-бота
С++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); }#include <iostream>
using namespace std;
int main(){ cout << "Vvedute kol-vo ocenok" << endl;
int n,i,a,Four,Five; n = i = a = Four = Five = 0;
cin >> n;
for (i = 1; i <= n; i++) { cin >> a; if (a == 4){ Four++;} else if (a == 5) { Five++; } } if (Four > Five){ cout << "Four" << endl;} else if (Five > Four) { cout << "Five" << endl; } else { cout << "Equal"<< endl; } cout << "Kol-vo 4: " << Four << " Kol-vo 5: " << Five << endl; return 0;}