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

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

8S 2G 3C 1S 2C