# Include <iostream>
# Include <cstring>
# Include <cstdio>
Using namespace STD;
Const int nmax= 1000;
Class edge {
Public:
Int V, NEX;
}; Edge e [Nmax];
Int N, K, head [Nmax]; // head [I] is the head of the linked list starting from vertex I.
Void addedge (int A, int B) {// an algorithm for adding an edge to a graph, note that the following node with directed edge/B as a is a ----> B
E [K]. V = B;
E [K]. NEX = head [a];
Head [a] = K;
K ++;
}
Int main (){
Int I, A, B, W, k = 1;
Scanf ("% d", & N );
Memset (Head, 0, sizeof (head ));
For (I = 0; I <n; I ++ ){
Scanf ("% d", & A, & B );
Addedge (a, B); // Add an edge directed by A to B
}
Cin> W; // output the point pointed to by W.
For (I = head [w]; I; I = E [I]. NEX ){
Cout <E [I]. v <Endl;
}
Cout <"End \ n ";
Return 0;
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.