PersonalCorpus 版 (精华区)

41705 2002-10-15 03:09:18 Accepted
1244 C++ 00:00.00 380K Big Guava

int main()
{
#ifndef ONLINE_JUDGE
    freopen("c:\\0acm\\zju\\i1244","r",stdin);
    freopen("c:\\0acm\\zju\\o1244","w",stdout);
#endif

    int n,t=0,i,j,k,left,right;
    bool mark [26],ok;
    char s[100];
    
    while (1) {
        scanf("%d\n",&n);
        if (n==0) break; else t++;
        memset(mark,0,sizeof(mark)); mark[0]=true;
        for (i=0;i<n;i++) {
            gets(s);
            j=0; while (!isalpha(s[j])) j++;
            left=s[j]-97;
            j++; while (!isalpha(s[j])) j++;
            right=s[j]-97;
            mark[left]=mark[right];
        }
        printf("Program #%d\n",t);
        ok=false;
        for (i=0;i<26;i++) if (mark[i]) { printf("%c ",i+97); ok=true; 
}
        if (!ok) printf("none");
        printf("\n\n");
    }
}
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:1.894毫秒