Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program LilPip;
- {$APPTYPE CONSOLE}
- uses
- SysUtils,
- Math;
- var
- Thousands, Hundreds, Decades, Units, Number: Integer;
- const
- TEN = 10;
- HUNDRED = 100;
- THOUSAND = 1000;
- procedure Zero(var a,b,c,d: Integer);
- begin
- a := 0;
- b := 0;
- c := 0;
- d := 0;
- end;
- // Below procedure monitors rank overflows.
- procedure RankStep(var PrevRank,ProcessingRank,Counter: Integer;
- const CheckRank: integer);
- begin
- if Counter mod CheckRank = 0 then
- begin
- ProcessingRank := ProcessingRank + 1;
- PrevRank := PrevRank - 10;
- end;
- end;
- procedure main (var g,f:integer);
- var i: integer;
- begin
- Zero(Thousands, Hundreds, Decades, Units);
- write ('Hello, this program will find number of all car numbers,');
- writeln (' that have 3 same digits');
- f := 1;
- for i := 1 to 9999 do
- begin
- Inc (g);
- RankStep(Units, Decades, i, TEN);
- RankStep(Decades, Hundreds, i, HUNDRED);
- RankStep(Hundreds, Thousands, i, THOUSAND);
- if ((Thousands = Hundreds) and (Hundreds = Decades))
- or ((Hundreds = Decades) and (Hundreds = Units))
- or ((Thousands = Decades) and (Thousands = Units))
- or ((Thousands = Hundreds) and (Thousands = Units)) then
- begin
- writeln (Thousands, Hundreds, Decades, Units);
- inc (f);
- end;
- end;
- write ('Number of car numbers: ',Number + 1);
- readln;
- end;
- begin
- main(Units,Number);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement