vigura2
14.01.2022 21:42

Паскаль нужно объяснить, как работает программа. Пошагово и с объяснением. Даны два очень длинных целых числа (возможные значения превышают диапазон значений longint). Сложите эти числа

Program kursayin_khndir_2;
Type arr = array [1..100] of integer;
var
s1, s2, s3: string;
n1, n2, n3, l1, l2, l3, i: byte;
c: string[1];
begin
writeln('Ներմուծել 1 թիվը ');
readln(s1);
writeln('Ներմուծել 2 թիվը ');
readln(s2);
l1 := length(s1);
l2 := length(s2);
if l1 > l2 then begin
s3 := s1; l3 := l1;
s1 := s2; l1 := l2;
s2 := s3; l2 := l3;
end;
s3 := ''; n3 := 0;
for i := l1 downto 1 do begin
val(s1[i], n1);
val(s2[l2], n2);
l2 := l2 - 1;
str((n1 + n2 + n3) mod 10, c);
s3 := c + s3;
if n1 + n2 + n3 > 9 then
n3 := 1
else n3 := 0;
end;
while n3 = 1 do begin
if l2 <> 0 then begin
val(s2[l2], n2);
l2 := l2 - 1;
str((n2 + n3) mod 10, c);
s3 := c + s3;
if n2 + n3 < 10 then
n3 := 0;
end
else begin
s3 := '1' + s3;
n3 := 0;
end;
end;
if l2 <> 0 then
s3 := copy(s2, 1, l2) + s3;
writeln('1 և 2 թվերի գումարը ');
writeln(s3);
end.

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
Hеll
15.03.2022 00:57

#include <iostream>

#include <vector>

#include <cmath>

using namespace std;

struct river{

   string name;

   double length;

   double depth;

   bool ships;

};

signed main(){

   int n;

   cin >> n;

   river a[n];

   for(int i = 0; i < n; i++)

       cin >> a[i].name >> a[i].length >> a[i].depth >> a[i].ships;

   vector<river> ans;

   for(auto i: a)

       if(i.length > 2 && i.ships)

           ans.push_back(i);

   for(auto i: ans){

       cout << "name: " << i.name << "\n";

       cout << "length: " << i.length << "\n";

       cout << "depth: " << i.depth << "\n";

       cout << "ships?: Yes";

   }

}

0,0(0 оценок)
Ответ:
korobkovaangelina
15.03.2022 00:57

#include <iostream>

#include <vector>

#include <cmath>

using namespace std;

struct river{

   string name;

   double length;

   double depth;

   bool ships;

};

signed main(){

   int n;

   cin >> n;

   river a[n];

   for(int i = 0; i < n; i++)

       cin >> a[i].name >> a[i].length >> a[i].depth >> a[i].ships;

   vector<river> ans;

   for(auto i: a)

       if(i.length > 2 && i.ships)

           ans.push_back(i);

   for(auto i: ans){

       cout << "name: " << i.name << "\n";

       cout << "length: " << i.length << "\n";

       cout << "depth: " << i.depth << "\n";

       cout << "ships?: Yes";

   }

}

0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота