Advertisement
maxlarin2

comb_alg_pascal

Mar 8th, 2014
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.17 KB | None | 0 0
  1. uses
  2.   timers, utils;
  3.  
  4. const
  5.   length = 20000;
  6.  
  7. type
  8.   DateTime = record
  9.     Day, Month, Year, Hour, Minute, Second, Milliseconds: integer;
  10.   end;
  11.  
  12. var
  13.   q, i, j, n, m, min, tmp: integer;
  14.   mas: array [1..length] of integer;
  15.   t, f, address: text;
  16.   taddress: string;
  17.  
  18.  
  19. begin
  20.  
  21.   assign(address, 'adress.txt');
  22.   reset(address);
  23.   assign(f, 'output.txt');
  24.   append(f);
  25.   while (not eof(address)) do
  26.   begin
  27.     readln(address, taddress);
  28.     assign(t, taddress);
  29.     reset(t);
  30.     delete(taddress, (pos('_', taddress)), taddress.Length);
  31.     n := strtoint(taddress);
  32.     while (not eof(t)) do
  33.     begin
  34.       while(not eoln (t)) do
  35.       begin
  36.         inc(q);
  37.         read(t, mas[q]);
  38.       end;
  39.       readln(t);
  40.     end;
  41.     tmp := milliseconds();
  42.     for i := 1 to n - 1 do
  43.     begin
  44.       m := i;
  45.       min := mas[i];
  46.       for j := i + 1 to n do
  47.       begin
  48.         if mas[j] < min then
  49.         begin
  50.           min := mas[j];
  51.           m := j;
  52.         end;
  53.       end;
  54.       mas[m] := mas[i];
  55.       mas[i] := min;
  56.     end;
  57.     tmp := milliseconds() - tmp;
  58.     writeln(f, taddress, ' ', tmp);
  59.   end;
  60.   close(t);
  61.   close(f);
  62. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement