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. procedure readcard(var s: ansistring; var number: longint; var suit: char);
  10. begin
  11. if (s[1] = '1') and (s[2] = '0') then
  12. begin
  13. number := 10;
  14. suit := s[3];
  15. s := copy(s, 5, length(s));
  16. end else begin
  17. number := ord(s[1]) - ord('0');
  18. suit := s[2];
  19. s := copy(s, 4, length(s));
  20. end;
  21. end;
  22.  
  23.  
  24.  
  25. begin
  26. {
  27.   uncomment the following lines if you want to read/write from files
  28.   assign(input, 'input.txt'); reset(input);
  29.   assign(output, 'output.txt'); rewrite(output);
  30. }
  31.  
  32. readln(line);
  33. for i:=1 to 3 do
  34. begin
  35. { card in hand }
  36. readcard(line, number, suit);
  37. writeln (line);
  38. manonum[i]:=number; manosui[i]:=suit;
  39. { use number and suit }
  40. end;
  41. tot:=0;
  42. readln(line);
  43. for i:=1 to 4 do
  44. begin
  45. { card on table }
  46. readcard(line, number, suit);
  47. writeln(line);
  48. tavolonum[i]:=number; tavolosui[i]:=suit;
  49. tot:=tot+number;
  50. { use number and suit }
  51. end;
  52.  
  53. 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;
  54.  
  55.  
  56.  
  57. end.
  58.  
Success #stdin #stdout 0s 5308KB
stdin
5G 7S 8S
2G 3C 1S 2C

stdout
7S 8S
8S

3C 1S 2C
1S 2C
2C

8S 2G 3C 1S 2C