Предмет: Информатика, автор: Аноним

Будем называть два числа дружественными, если они состоят из одних и тех же цифр. Например, числа 1132 и 32321 является дружественными, а 12 и 123 нет (в первом числе нет цифры 3). Напишите программу, определяющую являются ли два заданных числа дружественными.

Входные данные: Ввести два целых числа A и B, разделенных одним пробелом, (0
Выходные данные: Вывести сообщение YES, если A и B являются дружественными, или NO, если не являются.

Ответы

Автор ответа: fedrfedr
1

Ответ:

program Friendly;

uses

 SysUtils;   // для IntToStr

var

 a, b, i, pa, pb: LongInt;

 sa, sb: string;

 f: Boolean;

begin

 Write ('A, B = ');

 ReadLn (a, b);

 sa := IntToStr (a);

 sb := IntToStr (b);

 f := True;

 for i := 0 to 9 do begin

   pa := Pos (IntToStr (i), sa);

   pb := Pos (IntToStr (i), sb);

   if ((pa <> 0) and (pb = 0)) or ((pa = 0) and (pb <> 0)) then begin

     f := False;

     Break;

   end;

 end;

 if f then

   WriteLn ('YES')

 else

   WriteLn ('NO');

 ReadLn;

end.


Аноним: программа работает верно,чекнула в паскале,но жюри не принимает такой ответ,не знаю почему))
fedrfedr: более простого решения я не вижу, а что за жюри, если не секрет
Аноним: я чутка подправила,и все терь намана спасибо,приняли))
fedrfedr: где-то ошибка была?
Похожие вопросы
Предмет: Английский язык, автор: Mb333333
СРОЧНО НУЖНА ПОМОЩЬ
II. Grammar Test
1. Complete the sentences
1) He hasn’t locked the door, ….?
2) You will meet Max at 5, ….?
3) I went to the mountains last winter, ….?
4) It often snows in winter, ….?
1. Fill the gaps using the necessary prepositions.
5) My elder brother studies …Medical University. a) on b) at
6) Look! That cat jumped …. the roof of your car. a) info b) onto
7) We live …. the twenty-first century. a) on b) in c) at
8) There is a big round table… the room.
a) under b) between c) in the middle of
3. Choose the right variant
9) I see …(he) too. a) her b) him c) them d) us
10) I met my grandmother in the perk yesterday. … was very glad to see us.
a) I b) He c) She d) They
11) My car is faster than … (your car).
a) his b) hers c) mine d) yours
12) My mother works in a hospital . … is a doctor
a) we b) she c) he d) I
IV. Fill the gaps with the necessary adjectives.
13) The Nile is the … river in the world. a) long b) longer c) the longest
14) Hippos are …animals. a) bigger b) big c) the biggest
15) We stayed in …hotel in the whole city. a) bad b) worse c) the worst16) Her teachers say that she is …student in the school.
a) good b) the best c) better
V. Choose the right variant
17) This baby … walk yet. a) mustn’t b) can’t c) couldn’t
18) You …finish all the work yesterday. a) could b) may c) can
19) I … sleep will yesterday. a) can’t b) mustn’t c) couldn’t
20) Max …take my umbrella. a) must b) can c) may
VI. Choose the right form of the verb.
21) I… a thrilling story right now.
a) has read b) read c) reads d) am reading
22) My grandmother often … on the phone.
a) is talking b) talks c) has talked d) talked
23) Last night my elder brother …our mother about the house.
a) helped b) is helping c) was helping d) has helped
24) He … a poem yesterday.
a) translated b) was translating c) has translated
Предмет: Математика, автор: Diana497d
Предмет: Математика, автор: marselkuba
Предмет: История, автор: Ученик41111