fork download
  1. program scopa;
  2.  
  3. var
  4. line: ansistring;
  5. i,j, number, tot: longint;
  6. suit: char;
  7. manonum, tavolonum:array[1..4] of integer;
  8. manosui, tavolosui:array[1..4] of char;
  9. setteinmano, setteintable:array[1..4] of boolean;
  10. procedure readcard(var s: ansistring; var number: longint; var suit: char);
  11. begin
  12. if (s[1] = '1') and (s[2] = '0') then
  13. begin
  14. number := 10;
  15. suit := s[3];
  16. s := copy(s, 5, length(s));
  17. end else begin
  18. number := ord(s[1]) - ord('0');
  19. suit := s[2];
  20. s := copy(s, 4, length(s));
  21. end;
  22. end;
  23.  
  24.  
  25.  
  26. begin
  27. {
  28.   uncomment the following lines if you want to read/write from files
  29.   assign(input, 'input.txt'); reset(input);
  30.   assign(output, 'output.txt'); rewrite(output);
  31. }
  32.  
  33. readln(line);
  34. for i:=1 to 4 do setteinmano[i]:=false; (*1=G,2=S,3=C,4=B*)
  35. for i:=1 to 4 do setteintable[i]:=false;
  36. for i:=1 to 3 do
  37. begin
  38. { card in hand }
  39. readcard(line, number, suit);
  40. if (number=7) and (suit='G') then setteinmano[1]:=true;
  41. if (number=7) and (suit='S') then setteinmano[2]:=true;
  42. if (number=7) and (suit='C') then setteinmano[3]:=true;
  43. if (number=7) and (suit='B') then setteinmano[4]:=true;
  44. writeln (line);
  45. manonum[i]:=number; manosui[i]:=suit;
  46. { use number and suit }
  47. end;
  48. tot:=0;
  49. readln(line);
  50. for i:=1 to 4 do
  51. begin
  52. { card on table }
  53. readcard(line, number, suit);
  54. writeln(line);
  55. if (number=7) and (suit='G') then setteintable[1]:=true;
  56. if (number=7) and (suit='S') then setteintable[2]:=true;
  57. if (number=7) and (suit='C') then setteintable[3]:=true;
  58. if (number=7) and (suit='B') then setteintable[4]:=true;
  59. tavolonum[i]:=number; tavolosui[i]:=suit;
  60. tot:=tot+number;
  61. { use number and suit }
  62. end;
  63.  
  64. for i:=1 to 3 do if setteinmano[1]=true then begin j:=2; while ((setteintable[j]=false) and (j<=4)) do j:=j+1; if j<5 then writeln ('7G',' ','7',setteintable[j])end;
  65. for i:=1 to 3 do if manonum[i]=tot then write (manonum[i],manosui[i],' '); for j:=1 to 4 do write(tavolonum[j],tavolosui[j],' '); writeln;
  66.  
  67.  
  68.  
  69. end.
Success #stdin #stdout 0s 5304KB
stdin
5 G 7 G 8 S
2 G 3 C 7 S 2 C
stdout
 7 G 8 S
G 8 S
 S
 3 C 7 S 2 C
C 7 S 2 C
 S 2 C
2 C
2  -163 19  -16S