Advertisement
dxvmxnd

Untitled

Oct 9th, 2023
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.87 KB | None | 0 0
  1. Program L2_2_D;
  2. Uses System.SysUtils;
  3. Var
  4.     IsCorrect : Boolean;
  5.     P, Result : Integer;
  6.  
  7. Function RemoveZerosFromNumber(Num: Integer): Integer;
  8. Var
  9.     Multiplier : Integer;
  10. Begin
  11.     Result := 0;
  12.     Multiplier := 1;
  13.  
  14.     While Num > 0 Do
  15.     Begin
  16.         If Num Mod 10 <> 0 Then
  17.         Begin
  18.             Result := Result + (Num mod 10) * Multiplier;
  19.             Multiplier := Multiplier * 10;
  20.         End;
  21.         Num := Num div 10;
  22.     End;
  23.     Result := Result;
  24. End;
  25.  
  26. Begin
  27.     Repeat
  28.         IsCorrect := True;
  29.         Write('Введите натуральное число P: ');
  30.         Try
  31.             Readln(P);
  32.         Except
  33.             Writeln('Неверный тип данных');
  34.             IsCorrect := False;
  35.         End;
  36.     Until IsCorrect;
  37.  
  38.     Result := RemoveZerosFromNumber(P);
  39.     Writeln(Result);
  40.     Readln;
  41.  
  42. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement