about summary refs log tree commit diff
path: root/daily
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-20 10:33:39 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-20 10:33:39 +0700
commitf2d4bc6b7c302dee2d84a3acf84b83b5a98c45fa (patch)
treed40c38af8709309f51f3cf82bcbc2b44dbfaa3b7 /daily
parentd40c9b81db3caff8ecca79df92241bc0c28a468c (diff)
downloadcp-f2d4bc6b7c302dee2d84a3acf84b83b5a98c45fa.tar.gz
More parentheses
Diffstat (limited to 'daily')
-rw-r--r--daily/302hard/bargroup.pas32
1 files changed, 11 insertions, 21 deletions
diff --git a/daily/302hard/bargroup.pas b/daily/302hard/bargroup.pas
index 295c458..de3c46a 100644
--- a/daily/302hard/bargroup.pas
+++ b/daily/302hard/bargroup.pas
@@ -1,4 +1,4 @@
-uses math, sysutils;
+uses math, strutils, sysutils;
 
 var
   minx, maxx, miny, maxy, stepx, stepy, i, x0, f: integer;
@@ -22,18 +22,6 @@ function gcd(a, b: integer): integer;
   end;
 
 
-function rjust(
-  s: string;
-  width: byte;
-  fill: char
-): string;
-  begin
-    while length(s) < width do
-      s := fill + s;
-    rjust := s
-  end;
-
-
 begin
   read(minx, maxx, miny, maxy, stepx, n);
   setlength(raw_freq, maxx - minx + 1);
@@ -69,19 +57,21 @@ begin
   setlength(xtrue, length(freq));
   for i := 0 to length(freq) - 1 do
     begin
-      xtrue[i] := rjust('', length(inttostr(minx + stepx * i)), '*');
-      xfalse[i] := rjust('', length(inttostr(minx + stepx * i)), ' ');
+      xtrue[i] := addchar('*', '', length(inttostr(minx + stepx * i)));
+      xfalse[i] := addchar(' ', '', length(inttostr(minx + stepx * i)));
       for j := 1 to stepx - 1 do
         begin
-          xtrue[i] := xtrue[i] +
-                      rjust('', length(inttostr(minx + stepx*i + j)) + 1, '*');
-          xfalse[i] := xfalse[i] +
-                       rjust('', length(inttostr(minx + stepx*i + j)) + 1, ' ')
+          xtrue[i] :=
+            xtrue[i] +
+            addchar('*', '', length(inttostr(minx + stepx*i + j)) + 1);
+          xfalse[i] :=
+            xfalse[i] +
+            addchar(' ', '', length(inttostr(minx + stepx*i + j)) + 1)
         end
     end;
 
   repeat
-    write(rjust(inttostr(maxy), lenf, ' '));
+    write(addchar(' ', inttostr(maxy), lenf), ' ');
     for i := 0 to length(freq) - 2 do
       begin
         if freq[i] >= maxy then
@@ -97,7 +87,7 @@ begin
     dec(maxy, stepy)
   until maxy < miny;
 
-  write(rjust('', lenf, ' '));
+  write(addchar(' ', '', lenf + 1));
   for i := minx to maxx - 1 do
     write(i, ' ');
   writeln(maxx)