Posted on 2008-05-08 15:28
superman 阅读(252)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1244 C++ 00:00.00 836K */
2 #include <iostream>
3
4 using namespace std;
5
6 int main()
7 {
8 int n, m = 1;
9 while((cin >> n) && n)
10 {
11 getchar();
12 bool x[26] = { true };
13
14 char v1, v2;
15 for(int i = 0; i < n; i++)
16 {
17 scanf("%c = %c", &v1, &v2); getchar();
18 v1 -= 'a', v2 -= 'a';
19 if(x[v2])
20 x[v1] = true;
21 else
22 x[v1] = false;
23 }
24
25 cout << "Program #" << m++ << endl;
26
27 int cnt = 0;
28 for(int i = 0; i < 26; i++)
29 if(x[i])
30 {
31 cnt++;
32 cout << char(i + 'a') << ' ';
33 }
34 if(cnt == 0)
35 cout << "none";
36 cout << endl << endl;
37 }
38
39 return 0;
40 }
41