Advertisement
dxvmxnd

Untitled

Sep 6th, 2024
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. Program Lab2_1;
  2.  
  3. Uses
  4. System.SysUtils;
  5.  
  6. Var
  7. Num : Integer;
  8. IsCorrect : Boolean;
  9. Sum : Integer;
  10.  
  11. Begin
  12. Writeln('Данная задача находит бла бла бла');
  13.  
  14. Repeat
  15. IsCorrect := True;
  16. Writeln('Введите Num');
  17. Try
  18. Readln(Num);
  19. Except
  20. IsCorrect := False;
  21. End;
  22. If ((Not IsCorrect) Or (Num < 1)) Then
  23. Begin
  24. IsCorrect := False;
  25. Writeln('Ошибка!');
  26. End;
  27. Until IsCorrect;
  28.  
  29. Sum := 0;
  30.  
  31. While (Num > 0) Do
  32. Begin
  33. Sum := Sum + (Num Mod 10);
  34. Num := Num Div 10;
  35. End;
  36.  
  37. Writeln('Sum = ', Sum);
  38.  
  39. Readln;
  40.  
  41.  
  42. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement