М
Молодежь
К
Компьютеры-и-электроника
Д
Дом-и-сад
С
Стиль-и-уход-за-собой
П
Праздники-и-традиции
Т
Транспорт
П
Путешествия
С
Семейная-жизнь
Ф
Философия-и-религия
Б
Без категории
М
Мир-работы
Х
Хобби-и-рукоделие
И
Искусство-и-развлечения
В
Взаимоотношения
З
Здоровье
К
Кулинария-и-гостеприимство
Ф
Финансы-и-бизнес
П
Питомцы-и-животные
О
Образование
О
Образование-и-коммуникации

Написать комментарии к коду. Программирование С++ Нужно пояснение кода. Код с комментариями.
#include
#include
#include
#include
#include
#include
#include

using namespace std;
class Rational
{
public:
Rational() //конструктор по умолчанию
{
num = 0;
den = 1;
}
Rational(int numerator, int denominator)
{
if (denominator 0 && b > 0)
{
if (a > b)
{
a %= b;
}
else
{
b %= a;
}
}//while
return a + b;
}
};
bool operator == (Rational a, Rational b) /перезгузим оператор ==
{
if ((a.Numerator() == b.Numerator()) && (a.Denominator() == b.Denominator()))
{
return true;
}
else {
return false;
}
}

bool operator > (Rational a, Rational b) ) /перезгузим оператор ==
{
return (a.Numerator() / (double)a.Denominator()) > double(b.Numerator() / (double)b.Denominator()); ) /перезгузим оператор ==
}
bool operator < (Rational a, Rational b)
{

return (a.Numerator() / (double)a.Denominator()) < (b.Numerator() / (double)b.Denominator());
}

int main() {
{
const set rs = { {1, 2}, {1, 25}, {3, 4}, {3, 4}, {1, 2} };
if (rs.size() != 3) {
cout << "Wrong amount of items in the set" << endl;
return 1;
}

vector v;
for (auto x : rs) {
v.push_back(x);
}
if (v != vector{ {1, 25}, { 1, 2 }, { 3, 4 }}) {
cout << "Rationals comparison works incorrectly" << endl;
return 2;
}
}

{
map count;
++count[{1, 2}];
++count[{1, 2}];
++count[{2, 3}];

if (count.size() != 2) {
cout << "Wrong amount of items in the map" << endl;
return 3;
}
}
cout << "OK" << endl;
return 0;
}

👇
Открыть все ответы
Ответ:
212629
212629
22.04.2020
1.
var
  s: string;
  i, count: integer;
begin
  writeln('Vvedite stroky: ');
  readln(s);
  for i := 1 to length(s) - 2 do
    if copy(s, i, 3) = 'abc' then
      count := count + 1;
  writeln('Kol-vo: ', count);
end.
2.
var
  s1, s2: string;
  i, len1, len2: integer;
begin
  writeln('Vvedite stroky 1: ');
  readln(s1);
  writeln('Vvedite stroky 2: ');
  readln(s2);
  len1 := length(s1);
  len2 := length(s2);
  if len1 > len2 then writeln('1 stroka dlinnee')
  else if len1 < len2 then writeln('2 stroka dlinnee')
  else writeln('dlini strok ravnie')
end.
3.
var
  s1, s2, s3: string;
begin
  writeln('Vvedite stroky 1: ');
  readln(s1);
  writeln('Vvedite stroky 2: ');
  readln(s2);
  s3 := s1[1] + s1[2] + s2[1] + s2[2];
  writeln('Novaja stroka: ', s3);
end.
4,7(77 оценок)
Ответ:
арина1382
арина1382
22.04.2020
Rem BASIC-256
cls
errors = 0
print "Введите текст > ";

rem Пользователь вводит текст
input a$

rem Перебираем все буквы с начала и до предпоследней
for i=1 to length(a$)-1

rem Если встречаем букву Ч или Щ
if mid(a$, i, 1) = "ч" or mid(a$, i, 1) = "щ" then

rem Тогда проверяем следующую за ней букву.
rem Если это буква я, тогда подсчитываем очередную ошибку
if mid(a$, i + 1, 1) = "я" then errors = errors + 1
end if

rem Переходим к следующей букве
next i

rem Вывод результата
print "Количество ошибок в тексте ";
print errors

rem Конец программы
end
4,5(18 оценок)
Новые ответы от MOGZ: Информатика
logo
Вход Регистрация
Что ты хочешь узнать?
Спроси Mozg
Открыть лучший ответ