fork download
  1. program scopa;
  2. Uses math;
  3. type carta = record
  4. numero:integer;
  5. seme:char
  6. end;
  7. var
  8. line: ansistring;
  9. c:integer;
  10. i,j, h, t, tot, number, ricordaid, conta, ricordaconta, ricordatot: integer;
  11. suit: char;
  12. mano, table, ricorda: array[1..4] of carta;
  13. settebinmano, settebintable, fattoscopa: boolean;
  14.  
  15. procedure readcard(var s: ansistring; var number: integer; var suit: char);
  16. begin
  17. if (s[1] = '1') and (s[2] = '0') then
  18. begin
  19. number := 10;
  20. suit := s[3];
  21. s := copy(s, 5, length(s));
  22. end else begin
  23. number := ord(s[1]) - ord('0');
  24. if ord(s[2])<>32 then
  25. begin
  26. suit := s[2];
  27. s := copy(s, 4, length(s));
  28. end
  29. else
  30. begin
  31. suit := s[2+1];
  32. s := copy(s, 4+1, length(s));
  33. end;
  34. end;
  35. end;
  36.  
  37.  
  38.  
  39. begin
  40. {
  41.   uncomment the following lines if you want to read/write from files
  42.   assign(input, 'input.txt'); reset(input);
  43.   assign(output, 'output.txt'); rewrite(output);
  44. }
  45. settebinmano:=false; settebintable:=false; fattoscopa:=false;
  46.  
  47. readln(line);
  48. for i:=1 to 3 do
  49. begin
  50. { card in hand }
  51. readcard(line, number, suit);
  52. writeln (line);
  53. mano[i].numero:=number;
  54. mano[i].seme:=suit;
  55. if (number=7) and (suit='G') then settebinmano:=true;
  56. { use number and suit }
  57. end;
  58. for i:=1 to 3 do begin ricorda[i].numero:=0; ricorda[i].seme:='0'; end;
  59. readln(line);
  60. tot:=0;
  61. for i:=1 to 4 do
  62. begin
  63. { card on table }
  64. readcard(line, number, suit);
  65. writeln(line);
  66. table[i].numero:=number;
  67. table[i].seme:=suit;
  68. tot:=tot+number;
  69. if (number=7) and (suit='G') then settebintable:=true;
  70. { use number and suit }
  71. end;
  72.  
  73. for t:=1 to 3 do
  74. begin
  75. for i:=1 to 16 do
  76. begin
  77. tot:=0;
  78. for j:=0 to 4 do
  79. begin
  80. if i And (1 Shl j) <>0 then tot:=tot + table[j].numero;
  81.  
  82. if tot=5 then write (mano[t].numero,mano[t].seme,' ',table[j].numero, table[j].seme);
  83. writeln;
  84. end;
  85.  
  86. end;
  87. end;
  88. end.
  89.  
Success #stdin #stdout 0s 5288KB
stdin
5G 7S 8S
2G 3C 1S 2C
stdout
7S 8S
8S

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




























5G 3C
5G 1S
5G 2C


5G 3C
5G 1S
5G 2C
































5G 3C




5G 3C


































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


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
































7S 3C




7S 3C


































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


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
































8S 3C




8S 3C