Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program DigitsSort;
- const
- N = 100;
- function randomInRange(n, m: integer): integer;
- begin
- randomInRange := Random(m - n + 1) + n;
- end;
- var
- arr: array[1..N] of integer;
- single_digits: array[1..N] of integer;
- double_digits: array[1..N] of integer;
- singles_counter, doubles_counter, i: integer;
- begin
- singles_counter := 0;
- doubles_counter := 0;
- for i := 1 to N do
- begin
- arr[i] := randomInRange(0, 25);
- Write(arr[i], ' ');
- end;
- WriteLn;
- for i := 1 to N do
- begin
- if (arr[i] >= 0) and (arr[i] < 10) then
- begin
- singles_counter := singles_counter + 1;
- single_digits[singles_counter] := arr[i];
- end
- else
- begin
- doubles_counter := doubles_counter + 1;
- double_digits[doubles_counter] := arr[i];
- end;
- end;
- for i := 1 to doubles_counter do
- begin
- singles_counter := singles_counter + 1;
- single_digits[singles_counter] := double_digits[i];
- end;
- for i := 1 to N do
- begin
- Write(single_digits[i], ' ');
- end;
- WriteLn;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement