fjnu 1673 Definite Values

Description

A common error in programming is to use variables that have not been initialized before. For example, in C and C++, all variables have an indefinite value after declaration - their value can be anything. Thus, the following program

main()
{
int x;
printf("%d
",x);
}

could print any number. But even in languages such as Pascal, where all values are initialized to zero, it is useful to give variables definite values before using them, the avoid side effects when your code portion is placed into a different context.

Generally, the problem of deciding for a given program whether all variables have been assigned values before they are read out, is undecidable. But if you, as in this problem, consider only a sequence of assignments, the problem becomes solvable.

Input

The input contains several program parts. Each part starts with a number n on a line by itself, the number of lines in the program part. The following n lines contain each an assignment of the form "variable1 = variable2", where the variablei's are lower-case letters.

The input is terminated by a test case starting with n = 0.

Output

Assume that before the execution of the given program part, variable a has some definite value, while all other variables are undefined. You have to print the names of the varaibles which have a definite value after the execution of the program part. More specifically, format your output as follows.

For each program part in the input, first print the number of the program, as shown in the sample output. Then print a line containing the names of the variables which have a definite value after the execution of the given program part. Print them in alphabetically sorted order, and leave one blank after each variable name. If none of the variables has a definite value after the execution of the program part, print the word "none".

Print a blank line after each test case.

Sample Input

4
b = a
c = d
d = b
e = f
1
a = b
0

Sample Output

Program #1
a b d

Program #2
none
 
KEY:这题以前说过了,不再说了……
 
 
Source:

#include
< iostream >
#include
< algorithm >
using   namespace  std;

struct  node
{
    
char c;
    
int flag;
}
;

class  List
{
    node elem[
30];
public:
    List()
    
{
        
int i;
        
for(i=1;i<=26;i++)
        
{
            elem[i].c
='a'+i-1;
            elem[i].flag
=0;
        }

        elem[
1].flag=1;
    }

    
int find(char x);
    
void insert(char A,char B);
    
void output();
}
;

int  List::find( char  x)
{
    
if(elem[x-96].flag==1return 1;
    
else return 0;
}


void  List::insert( char  A, char  B)
{
    
if(find(A)&&find(B)) return ;
    
if(find(A)&&!find(B))
    
{
        elem[A
-96].flag=0;
        
return ;
    }

    
if(!find(A)&&find(B)) 
    
{
        elem[A
-96].flag=1;
        
return ;
    }

    
if(!find(A)&&!find(B)) return ;
}


void  List::output()
{
    
int t=0;
    
int i;
    
for(i=1;i<=26;i++
        
if(elem[i].flag==1)
        
{
            cout
<<elem[i].c<<" ";
            t
++;
        }

    
if(t==0)
    
{
        cout
<<"none"<<endl;
        
return ;
    }

    cout
<<endl;
}



int  main()
{
//    freopen("1673.in","r",stdin);
    int T=1;
    
int N;
    
char A,B;
    
int q;
    
while(scanf("%d ",&N)!=EOF)
    
{
        
if(N==0break;
        cout
<<"Program #"<<T++<<endl;
        List L;
        
for(q=1;q<=N;q++)
        
{
            scanf(
"%c = %c ",&A,&B);
            L.insert(A,B);
        }

        L.output();
        cout
<<endl;
    }

    
return 0;
}




    





        
    







    
    




 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好,以下是一个简单的使用HTML制作类似于"https://www.fjnu.edu.cn/main.htm"网页的示例代码: ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>福建师范大学</title> </head> <body> <header> <h1>福建师范大学</h1> </header> <nav> <ul> <li><a href="#">首页</a></li> <li><a href="#">学校概况</a></li> <li><a href="#">新闻中心</a></li> <li><a href="#">招生就业</a></li> <li><a href="#">校园生活</a></li> <li><a href="#">教学科研</a></li> <li><a href="#">校友服务</a></li> </ul> </nav> <main> <article> <h2>学校简介</h2> <p>福建师范大学创建于1907年,是福建省人民政府与教育部共建高校。学校主要办学特色是师范教育和人文社会科学,具有百年办学历史和深厚的文化底蕴。</p> </article> <section> <h2>新闻动态</h2> <ul> <li><a href="#">福建师范大学2021年迎新工作启动</a></li> <li><a href="#">2021年福建师范大学教师招聘公告</a></li> <li><a href="#">福建师范大学2021年本科招生计划</a></li> </ul> </section> </main> <aside> <h2>联系我们</h2> <p>地址:福建省福州市闽侯县上街镇</p> <p>电话:0591-83442777</p> <p>邮箱:fjnu@fjnu.edu.cn</p> </aside> <footer> <p>© 2021 福建师范大学</p> </footer> </body> </html> ``` 在这个示例中,我们使用HTML5标记语言来创建网页。我们通过`<header>`元素来定义网页的标题,通过`<nav>`元素来定义网页的主要导航,通过`<main>`元素来定义网页的主要内容,通过`<aside>`元素来定义网页的侧边栏内容,通过`<footer>`元素来定义网页的页脚。在`<main>`元素中,我们使用`<article>`元素来定义学校简介部分的内容,使用`<section>`元素来定义新闻动态部分的内容。网页的样式和布局可以通过CSS来实现。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值