Войти
Регистрация
Спроси ai-bota
В
Все
М
Математика
О
ОБЖ
У
Українська мова
Х
Химия
Д
Другие предметы
Н
Немецкий язык
Б
Беларуская мова
М
Музыка
Э
Экономика
Ф
Физика
Б
Биология
О
Окружающий мир
У
Українська література
Р
Русский язык
Ф
Французский язык
П
Психология
О
Обществознание
А
Алгебра
М
МХК
Г
География
И
Информатика
П
Право
А
Английский язык
Г
Геометрия
Қ
Қазақ тiлi
Л
Литература
И
История
Показать больше
Показать меньше
nikitav109
10.06.2021 22:18 •
Информатика
Переведите единицы информации *
Показать ответ
Ответ:
svetaredkina
21.07.2020 09:56
#include <iostream>
#include <conio.h>
#include <time.h>
using namespace std;
void main()
{
srand(time(NULL));
setlocale(0, "");
int arr[17];
int a, b, chet=0, nechet = 0;
cout << "Введите диапазон ." << endl << "Нижняя граница диапазона: "; cin >> a; cout << "Верхняя граница диапазона: "; cin >> b; cout << endl;
for (int i = 0; i < 17; ++i)
{
arr[i] = a + rand() % (b-a+1);
cout <<" "<<arr[i];
}
for (int i = 0; i < 17; ++i)
{
if (arr[i] % 2 == 0) chet++;
else nechet++;
} if (chet > nechet)
cout << " \n Четных больше";
else if (nechet>chet)
cout << "\n Нечетных больше";
else cout << "\n Одинаковое количество четных и нечетных";
_getch();
}
0,0
(0 оценок)
Ответ:
kitmyfaded
14.10.2022 04:56
С++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 оценок)
Популярные вопросы: Информатика
VernerIgor
15.01.2020 00:50
Exel. пусть при откорме каждое животное ежедневно должно получать не менее 9 единиц питательного вещества s1, не менее 8 единиц питательного вещества s2 и не менее 12 единиц питательного...
NikaAs1
03.10.2020 16:37
1. Приведите примеры нелинейной последовательности событий. Как минимум 3 позиции. 2. Как выглядит размещение слайдов в режиме Сортировщика слайдов у нелинейной презентации в PowerPoint?...
гамов666
10.02.2023 00:20
Створіть проект, у якому вводяться значення елементів табличної величини з 15 piзних дійсних чисел у багаторядковому текстовому полі, визначається найменше серед значень її елементів...
Maria20511
06.08.2020 12:57
Как решать таблиц истиности объясните...
lizakiki1
08.01.2020 22:49
Синформатикой (определить значение z)...
byrzakovskaya
08.05.2022 19:27
Запиши число 15340 в развёрнутом виде, начиная со старшего разряда....
hikita07
06.06.2020 20:56
1. даны три нечетных числа – 3,7,1. результатом является среднее арифметическое данныхчисел. определите тип входных и выходных данных.переменные значения тип данных ...
Nagachika
29.12.2020 05:34
Составить и записать на одном из языков программирования. с клавиатуры вводятся три числа а,в,с.если а-чётное отрицательное,то вывести на экран значение суммы чисел а,в,с,иначе-значение...
nikitalarin843
27.09.2020 18:43
Как ты думаешь, почему числительные первый, второй и т.д называются порядковами ? на какой вопрос они отвечают?...
Bayleef
27.09.2020 18:43
Мельчайшие частицы , из которых состоят различные вещества , 1) атомы 2)электроны 3) нейтроны 4)молекулы...
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota
Оформи подписку
О НАС
О нас
Блог
Карьера
Условия пользования
Авторское право
Политика конфиденциальности
Политика использования файлов cookie
Предпочтения cookie-файлов
СООБЩЕСТВО
Сообщество
Для школ
Родителям
Кодекс чести
Правила сообщества
Insights
Стань помощником
ПОМОЩЬ
Зарегистрируйся
Центр помощи
Центр безопасности
Договор о конфиденциальности полученной информации
App
Начни делиться знаниями
Вход
Регистрация
Что ты хочешь узнать?
Спроси ai-бота
#include <conio.h>
#include <time.h>
using namespace std;
void main()
{
srand(time(NULL));
setlocale(0, "");
int arr[17];
int a, b, chet=0, nechet = 0;
cout << "Введите диапазон ." << endl << "Нижняя граница диапазона: "; cin >> a; cout << "Верхняя граница диапазона: "; cin >> b; cout << endl;
for (int i = 0; i < 17; ++i)
{
arr[i] = a + rand() % (b-a+1);
cout <<" "<<arr[i];
}
for (int i = 0; i < 17; ++i)
{
if (arr[i] % 2 == 0) chet++;
else nechet++;
} if (chet > nechet)
cout << " \n Четных больше";
else if (nechet>chet)
cout << "\n Нечетных больше";
else cout << "\n Одинаковое количество четных и нечетных";
_getch();
}
С++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); }