Advertisement
RokasC

2014 Logo

Jun 15th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. program BevardΔ—15;
  2. type
  3. mas = array [1..100] of integer;
  4. var
  5. F : text;
  6. i, j, kiek, sum, sum1, sum2, task, task1, task2, geriaus : integer;
  7. A, B, C : mas;
  8.  
  9. //------------Funkcija - Geriausias --------
  10. function geriausias : integer;
  11. begin
  12. for i :=1 to kiek do
  13. begin
  14. if (task > task1) and (task > task2) then geriaus := 1;
  15. if (task1 > task2) and (task1 > task) then geriaus := 2;
  16. if (task2 > task1) and (task2 > task) then geriaus := 3;
  17. end;
  18. end;
  19.  
  20. //-------------- Skaitymas ----------------
  21. procedure skaitymas;
  22. begin
  23. sum := 0;
  24. Assign (F, 'u1.txt');
  25. Reset (F);
  26. Readln (F, kiek);
  27. for i := 1 to kiek do
  28. readln (F, A[i], B[i], C[i]);
  29. for j := 1 to kiek do
  30. begin
  31. sum := sum + A[j]; sum1 := sum1 + B[j]; sum2 := sum2 + C[j];
  32. end;
  33. Close (F);
  34. end;
  35.  
  36. //-----------------------------------------
  37. procedure skaiciavimas;
  38. begin
  39. task := 0; task1 := 0;
  40. for i := 1 to kiek do
  41. begin
  42. if (A[i] > B[i]) and (A[i] > C[i]) then task := task +4;
  43. if (A[i] = B[i]) or (A[i] = C[i]) then task := task + 2;
  44. if (B[i] > A[i]) and (B[i] > C[i]) then task1 := task1 +4;
  45. if (B[i] = A[i]) or (B[i] = C[i]) then task1 := task1 + 2;
  46. if (C[i] > A[i]) and (C[i] > B[i]) then task2 := task2 +4;
  47. if (C[i] = A[i]) or (C[i] = B[i]) then task2 := task2 + 2;
  48. end;
  49. geriausias;
  50. end;
  51.  
  52. //---------------Rasymas---------------------
  53. procedure rasymas;
  54. begin
  55. Assign (F, 'u1rez.txt');
  56. rewrite (F);
  57. write (F, sum, ' ', sum1, ' ', sum2);
  58. writeln (F);
  59. write (F, task, ' ', task1, ' ', task2);
  60. writeln (F);
  61. writeln (F, geriaus);
  62. writeln (F);
  63.  
  64. Close (F);
  65. end;
  66. //-----------------------------------------
  67. begin
  68. skaitymas;
  69. skaiciavimas;
  70. rasymas;
  71. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement