Posted on 2008-04-01 16:55
superman 阅读(243)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1075 C++ 00:00.00 844K */
2 #include <string>
3 #include <iostream>
4
5 using namespace std;
6
7 int main()
8 {
9 string card[12];
10 cin >> card[0];
11 while(true)
12 {
13 for(int i = 1; i < 12; i++)
14 cin >> card[i];
15
16 cout << "CARDS: ";
17 for(int i = 0; i < 12; i++)
18 cout << card[i] << (i == 11 ? '\n' : ' ');
19
20 int count = 0;
21 for(int i = 0; i < 12; i++)
22 for(int j = i + 1; j < 12; j++)
23 for(int k = j + 1; k < 12; k++)
24 {
25 int p;
26 for(p = 0; p < 4; p++)
27 if( (card[i][p] == card[j][p] && card[j][p] == card[k][p] && card[i][p] == card[k][p]) ||
28 (card[i][p] != card[j][p] && card[j][p] != card[k][p] && card[i][p] != card[k][p]) );
29 else
30 break;
31
32 if(p == 4)
33 {
34 count++;
35 if(count == 1)
36 cout << "SETS: ";
37 else
38 cout << " ";
39 cout << count << ". " << card[i] << ' ' << card[j] << ' ' << card[k] << endl;
40 }
41 }
42 if(count == 0)
43 cout << "SETS: *** None Found ***" << endl;
44
45 if(cin >> card[0])
46 cout << endl;
47 else
48 break;
49 }
50
51 return 0;
52 }
53