Advertisement
CrazyDiver

write num with spaces between each decade

Dec 12th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.68 KB | None | 0 0
  1. procedure ReadNum(var inp:longint);
  2. begin
  3.   readln(inp);  //read num
  4. end;
  5. procedure WriteWthSpaces(n:longint);
  6. var dcd:longint;
  7. begin
  8.   dcd:=1;  //firslty num of decs eq 1
  9.   while n div dcd div 10>0 do   //while last discharge of first dcd discharges of inputted num manre than 0 do
  10.     dcd:=dcd*10;  //add one dischatge to dcd variable
  11.   repeat  //repear cycle until dcd value eq 0
  12.     Write(n div dcd mod 10,' ');  //write last discharge of first dcd discharges of inputted num and space
  13.     dcd:=dcd div 10;  //cut last dcd discharge
  14.   until dcd=0;  // end of the cycle
  15. end;
  16. var n: LongInt;
  17. begin
  18.   ReadNum(n);  //read num
  19.   WriteWthSpaces(n);  // write num wth spaces
  20. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement