k_vychodilova

HOKEJ

Dec 5th, 2020 (edited)
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 10.83 KB | None | 0 0
  1. program Hello;
  2. Uses sysutils,crt;
  3.  
  4. var
  5. tymy: array[1..4] of string;
  6. pole: array[1..5, 1..8] of string;  
  7. i,j:integer;
  8. x,y:string;
  9. a,b,c,p:string;
  10. a1,b1,c1,a2,b2,c2,x1,y1:integer;
  11. s1,s2,s3:integer;
  12.  
  13. h: array [1..4] of integer;     {poradi}
  14. r,mp:integer;                 {poradi}
  15.  
  16. p1: array [1..4] of boolean;     {poradi}
  17. p2: array [1..4] of boolean;    {poradi}
  18.  
  19. begin
  20. p:=('-');s1:=0;s2:=0;s3:=0;
  21. tymy[1]:='OLM' ;
  22. tymy[2]:='OST' ;
  23. tymy[3]:='HRA';
  24. tymy[4]:='HOL' ;
  25.   //clrscr();
  26.   writeln('                     Výpis týmů                          ');
  27.   writeln('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
  28.   writeln('1.TÝM:', tymy[1],',  2.TÝM: ',tymy[2],',  3.TÝM: ',tymy[3],',  4.TÝM: ',tymy[4]);
  29.   writeln('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<');
  30.  
  31.  
  32. for i:=1 to 4 do        // Vkladani tymu do TAB - R
  33.             begin
  34.             pole[1,i+1]:=tymy[i];
  35.             end;
  36. for i:=1 to 4 do        // Vkladani tymu do TAB - SL
  37.             begin
  38.             pole[i+1,1]:=tymy[i];
  39.             end;
  40. for i:=1 to 5 do        //Eliminace zápasů shodných družstev
  41.     begin
  42.     pole[i,i]:=('-----');
  43.     end;
  44. for i:=1 to 5 do
  45.     begin
  46.     pole[i,6]:=('||');
  47.     end;
  48. writeln('stiskni ENTER pro pokracovani');
  49. readln();    
  50. clrscr();
  51.  for i:=1 to 5 do
  52.     begin  
  53.         for j:=1 to 8 do
  54.         begin
  55.             write(' ',pole[i,j],' ');
  56.         end;
  57.         writeln;  
  58.     end;  
  59.  
  60.  
  61. //Vložení výsledků do tabulky
  62. writeln('ZADEJ VÝSLEDKY do tabulky ve tvaru X-Y');
  63. writeln('Výsledek zapasu ',tymy[1],' : ',tymy[2]);  // 1.zapas
  64.     readln(pole[2,3]);
  65.     x:=pole[2,3];
  66.     a:=x[1];b:=x[2];c:=x[3];
  67.     y:=(c+b+a);
  68.     pole[3,2]:=y;
  69.    
  70.     writeln('stiskni ENTER pro pokracovani');
  71.     readln();    
  72.     clrscr();
  73.      for i:=1 to 5 do
  74.         begin  
  75.             for j:=1 to 8 do
  76.             begin
  77.                 write(' ',pole[i,j],' ');
  78.             end;
  79.             writeln;  
  80.         end;  
  81. writeln('Výsledek zapasu ',tymy[1],' : ',tymy[3]); // 2.zapas
  82.     readln(pole[2,4]);
  83.     x:=pole[2,4];
  84.     a:=x[1];b:=x[2];c:=x[3];
  85.     y:=(c+b+a);
  86.     pole[4,2]:=y;
  87.     writeln('stiskni ENTER pro pokracovani');
  88.     readln();    
  89.     clrscr();
  90.      for i:=1 to 5 do
  91.         begin  
  92.             for j:=1 to 8 do
  93.             begin
  94.                 write(' ',pole[i,j],' ');
  95.             end;
  96.             writeln;  
  97.         end;
  98. writeln('Výsledek zapasu ',tymy[1],' : ',tymy[4]); //3. zapas
  99.     readln(pole[2,5]);          
  100.     x:=pole[2,5];
  101.     a:=x[1];b:=x[2];c:=x[3];
  102.     y:=(c+b+a);
  103.     pole[5,2]:=y;
  104.     writeln('stiskni ENTER pro pokracovani');
  105.     readln();    
  106.     clrscr();
  107.      for i:=1 to 5 do
  108.         begin  
  109.             for j:=1 to 8 do
  110.             begin
  111.                 write(' ',pole[i,j],' ');
  112.             end;
  113.             writeln;  
  114.         end;
  115. writeln('Výsledek zapasu ',tymy[2],' : ',tymy[3]);  //4. zapas
  116.     readln(pole[3,4]);
  117.     x:=pole[3,4];
  118.     a:=x[1];b:=x[2];c:=x[3];
  119.     y:=(c+b+a);
  120.     pole[4,3]:=y;
  121.     writeln('stiskni ENTER pro pokracovani');
  122.     readln();    
  123.     clrscr();
  124.      for i:=1 to 5 do
  125.         begin  
  126.             for j:=1 to 8 do
  127.             begin
  128.                 write(' ',pole[i,j],' ');
  129.             end;
  130.             writeln;  
  131.         end;
  132. writeln('Výsledek zapasu ',tymy[2],' : ',tymy[4]); //5. zapas
  133.     readln(pole[3,5]);
  134.     x:=pole[3,5];
  135.     a:=x[1];b:=x[2];c:=x[3];
  136.     y:=(c+b+a);
  137.     pole[5,3]:=y;
  138.     writeln('stiskni ENTER pro pokracovani');
  139.     readln();    
  140.     clrscr();
  141.      for i:=1 to 5 do
  142.         begin  
  143.             for j:=1 to 8 do
  144.             begin
  145.                 write(' ',pole[i,j],' ');
  146.             end;
  147.             writeln;  
  148.         end;
  149. writeln('Výsledek zapasu ',tymy[3],' : ',tymy[4]); //6. zapas
  150.     readln(pole[4,5]);
  151.     x:=pole[4,5];
  152.     a:=x[1];b:=x[2];c:=x[3];
  153.     y:=(c+b+a);
  154.     pole[5,4]:=y;
  155.     writeln('stiskni ENTER pro pokracovani');
  156.     readln();    
  157.     clrscr();
  158.      for i:=1 to 5 do
  159.         begin  
  160.             for j:=1 to 8 do
  161.             begin
  162.                 write(' ',pole[i,j],' ');
  163.             end;
  164.             writeln;  
  165.         end;
  166.  
  167. clrscr;
  168. writeln('Výsledná tabulka zápasů');
  169. writeln('---------------------------------------------------------------');
  170. pole[1,7]:=('SCORE');pole[1,8]:=('BODY');
  171.  
  172. a:=(pole[2,3][1]);b:=(pole[2,4][1]);c:=(pole[2,5][1]);          //1 tym; přistup pomocí indexů pole[2,3][1] na řádku 2,3 sloupec 1 znak obsahu
  173. a1:=StrToInt(a);b1:=StrToInt(b);c1:=StrToInt(c);x1:=a1+b1+c1;   //převod na číslo pro výpočet
  174. a:=(pole[2,3][3]);b:=(pole[2,4][3]);c:=(pole[2,5][3]);
  175. a2:=StrToInt(a);b2:=StrToInt(b);c2:=StrToInt(c);y1:=a2+b2+c2;
  176. x:=IntToStr(x1);y:=IntToStr(y1);pole[2,7]:=(x+p+y);
  177. if a1>a2 then s1:=s1+2 else if a1=a2 then s1:=s1+1;             //vyhodnocení na body
  178. if b1>b2 then s1:=s1+2 else if b1=b2 then s1:=s1+1;
  179. if c1>c2 then s1:=s1+2 else if c1=c2 then s1:=s1+1;
  180. h[1]:=s1;x:=IntToStr(s1);pole[2,8]:=x;s1:=0;s2:=0;s3:=0;
  181.  
  182. a:=(pole[3,2][1]);b:=(pole[3,4][1]);c:=(pole[3,5][1]);          // 2.tym, stejny postup
  183. a1:=StrToInt(a);b1:=StrToInt(b);c1:=StrToInt(c);x1:=a1+b1+c1;
  184. a:=(pole[3,2][3]);b:=(pole[3,4][3]);c:=(pole[3,5][3]);
  185. a2:=StrToInt(a);b2:=StrToInt(b);c2:=StrToInt(c);y1:=a2+b2+c2;
  186. x:=IntToStr(x1);y:=IntToStr(y1);pole[3,7]:=(x+p+y);
  187. if a1>a2 then s1:=s1+2 else if a1=a2 then s1:=s1+1;
  188. if b1>b2 then s1:=s1+2 else if b1=b2 then s1:=s1+1;
  189. if c1>c2 then s1:=s1+2 else if c1=c2 then s1:=s1+1;
  190. h[2]:=s1;x:=IntToStr(s1);pole[3,8]:=x;s1:=0;s2:=0;s3:=0;
  191.  
  192. a:=(pole[4,2][1]);b:=(pole[4,3][1]);c:=(pole[4,5][1]); {3.tym}
  193. a1:=StrToInt(a);b1:=StrToInt(b);c1:=StrToInt(c);x1:=a1+b1+c1;
  194. a:=(pole[4,2][3]);b:=(pole[4,3][3]);c:=(pole[4,5][3]);
  195. a2:=StrToInt(a);b2:=StrToInt(b);c2:=StrToInt(c);y1:=a2+b2+c2;
  196. x:=IntToStr(x1);y:=IntToStr(y1);pole[4,7]:=(x+p+y);
  197. if a1>a2 then s1:=s1+2 else if a1=a2 then s1:=s1+1;
  198. if b1>b2 then s1:=s1+2 else if b1=b2 then s1:=s1+1;
  199. if c1>c2 then s1:=s1+2 else if c1=c2 then s1:=s1+1;
  200. h[3]:=s1;x:=IntToStr(s1);pole[4,8]:=x;s1:=0;s2:=0;s3:=0;
  201.  
  202. a:=(pole[5,2][1]);b:=(pole[5,3][1]);c:=(pole[5,4][1]); {4.tym}
  203. a1:=StrToInt(a);b1:=StrToInt(b);c1:=StrToInt(c);x1:=a1+b1+c1;
  204. a:=(pole[5,2][3]);b:=(pole[5,3][3]);c:=(pole[5,4][3]);
  205. a2:=StrToInt(a);b2:=StrToInt(b);c2:=StrToInt(c);y1:=a2+b2+c2;
  206. x:=IntToStr(x1);y:=IntToStr(y1);pole[5,7]:=(x+p+y);
  207. if a1>a2 then s1:=s1+2 else if a1=a2 then s1:=s1+1;
  208. if b1>b2 then s1:=s1+2 else if b1=b2 then s1:=s1+1;
  209. if c1>c2 then s1:=s1+2 else if c1=c2 then s1:=s1+1;
  210. h[4]:=s1;x:=IntToStr(s1);pole[5,8]:=x;
  211.  
  212.  
  213.  
  214.  
  215.  
  216.   for i:=1 to 5 do
  217.     begin  
  218.         for j:=1 to 8 do
  219.         begin
  220.             write('  ',pole[i,j],' ');
  221.         end;
  222.         writeln;  
  223.     end;  
  224.  
  225.  
  226. writeln('--------------------------------');
  227. writeln();
  228. writeln('Stupně vítězů');
  229. writeln('--------------------------------');
  230. p1[1]:=false;p1[2]:=false;p1[3]:=false;p1[4]:=false; //p1 = >jestli je aktualne MAX}
  231. p2[1]:=false;p2[2]:=false;p2[3]:=false;p2[4]:=false; //p2 = >jestli uz je umisteny}
  232. r:=0;
  233. repeat {celkovy}
  234. begin
  235.     r:=r+1;
  236.     mp:=0;
  237.     i:=0;
  238.     repeat   {ZJISTENI MAX}
  239.     begin i:=i+1;
  240.         if (h[i]>mp) and (p2[i]=false) then mp:=h[i];
  241.     {p1[i]:=true     JE NEJVETSI}
  242.     end;
  243.     until i=4;
  244.  
  245.     j:=0;
  246.     repeat j:=j+1;   {MAX=== - JE VICE MAXU?}
  247.     if (h[j]=mp) and (p2[j]=false) then p1[j]:=true;
  248.     until j=4;
  249.     {p1[i]:=true     JE NEJVETSI}
  250.  
  251.  
  252. // kazdy ma sve poradi
  253.     if ((p1[1])=true) and ((p2[1])=false) then begin writeln(r,'. misto - ',tymy[1]);p2[1]:=true end;
  254.     if ((p1[2])=true) and ((p2[2])=false) then begin writeln(r,'. misto - ',tymy[2]);p2[2]:=true end;
  255.     if ((p1[3])=true) and ((p2[3])=false) then begin writeln(r,'. misto - ',tymy[3]);p2[3]:=true end;
  256.     if ((p1[4])=true) and ((p2[4])=false) then begin writeln(r,'. misto - ',tymy[4]);p2[4]:=true end;
  257.    
  258. // 2 tymy stejne poradi
  259. if ((p1[1])=true) and ((p1[2])=true) and ((p2[1])=false) and ((p2[2])=false) then begin writeln(r,'.-',r+1,'. misto - ',tymy[1]);writeln(r,'.-',r+1,'. misto - ',tymy[2]);r:=r+1;p2[1]:=true;p2[2]:=true end;
  260. if ((p1[1])=true) and ((p1[3])=true) and ((p2[1])=false) and ((p2[3])=false) then begin writeln(r,'.-',r+1,'. misto - ',tymy[1]);writeln(r,'.-',r+1,'. misto - ',tymy[3]);r:=r+1;p2[1]:=true;p2[3]:=true end;
  261. if ((p1[1])=true) and ((p1[4])=true) and ((p2[1])=false) and ((p2[4])=false) then begin writeln(r,'.-',r+1,'. misto - ',tymy[1]);writeln(r,'.-',r+1,'. misto - ',tymy[4]);r:=r+1;p2[1]:=true;p2[4]:=true end;
  262. if ((p1[2])=true) and ((p1[3])=true) and ((p2[2])=false) and ((p2[3])=false) then begin writeln(r,'.-',r+1,'. misto - ',tymy[2]);writeln(r,'.-',r+1,'. misto - ',tymy[3]);r:=r+1;p2[2]:=true;p2[3]:=true end;
  263. if ((p1[2])=true) and ((p1[4])=true) and ((p2[2])=false) and ((p2[4])=false) then begin writeln(r,'.-',r+1,'. misto - ',tymy[2]);writeln(r,'.-',r+1,'. misto - ',tymy[4]);r:=r+1;p2[2]:=true;p2[4]:=true end;
  264. if ((p1[3])=true) and ((p1[4])=true) and ((p2[3])=false) and ((p2[4])=false) then begin writeln(r,'.-',r+1,'. misto - ',tymy[3]);writeln(r,'.-',r+1,'. misto - ',tymy[4]);r:=r+1;p2[3]:=true;p2[4]:=true end;
  265.  
  266. //3 tymy stejne poradi
  267. if ((p1[1])=true) and ((p1[2])=true) and ((p1[3])=true) and ((p2[1])=false) and ((p2[2])=false) and ((p2[3])=false)
  268. then begin writeln(r,'.-',r+2,'. misto - ',tymy[1]);writeln(r,'.-',r+2,'. misto - ',tymy[2]);writeln(r,'.-',r+2,'. misto - ',tymy[3]);r:=r+2;p2[1]:=true;p2[2]:=true;p2[3]:=true end;
  269. if ((p1[1])=true) and ((p1[2])=true) and ((p1[4])=true) and ((p2[1])=false) and ((p2[2])=false) and ((p2[4])=false)
  270. then begin writeln(r,'.-',r+2,'. misto - ',tymy[1]);writeln(r,'.-',r+2,'. misto - ',tymy[2]);writeln(r,'.-',r+2,'. misto - ',tymy[4]);r:=r+2;p2[1]:=true;p2[2]:=true;p2[4]:=true end;
  271. if ((p1[1])=true) and ((p1[4])=true) and ((p1[3])=true) and ((p2[1])=false) and ((p2[4])=false) and ((p2[3])=false)
  272. then begin writeln(r,'.-',r+2,'. misto - ',tymy[1]);writeln(r,'.-',r+2,'. misto - ',tymy[4]);writeln(r,'.-',r+2,'. misto - ',tymy[3]);r:=r+2;p2[1]:=true;p2[4]:=true;p2[3]:=true end;
  273. if ((p1[4])=true) and ((p1[2])=true) and ((p1[3])=true) and ((p2[4])=false) and ((p2[2])=false) and ((p2[3])=false)
  274. then begin writeln(r,'.-',r+2,'. misto - ',tymy[4]);writeln(r,'.-',r+2,'. misto - ',tymy[2]);writeln(r,'.-',r+2,'. misto - ',tymy[3]);r:=r+2;p2[4]:=true;p2[2]:=true;p2[3]:=true end;
  275.  
  276.  
  277. // 4 tymy stejne poradi
  278. if ((p1[1])=true) and ((p1[2])=true) and ((p1[3])=true) and ((p1[4])=true) and ((p2[1])=false) and ((p2[2])=false) and ((p2[3])=false) and ((p2[4])=false)
  279. then begin writeln(r,'.-',r+3,'. misto - ',tymy[1]);writeln(r,'.-',r+3,'. misto - ',tymy[2]);writeln(r,'.-',r+3,'. misto - ',tymy[3]);writeln(r,'.-',r+3,'. misto - ',tymy[4]);p2[1]:=true;p2[2]:=true;p2[3]:=true;p2[4]:=true end;
  280.  
  281. end;
  282. until (p2[1]=true) and (p2[2]=true) and (p2[3]=true) and (p2[4]=true); //dokud nejsou vsechny p2 true, tdiz dokud nejsou vsechny vyhodnoceni
  283.  
  284.  
  285.  
  286.  
  287. end.
Add Comment
Please, Sign In to add comment