C language source code: [cpp] # include <stdio. h> # include <string. h> # define maxsize 1010 int E [maxsize] [maxsize]; char name [maxsize] [100]; int indegree [maxsize]; int Stack [maxsize]; int top; int find (char a []) {int I = 0; while (I <top) & (strcmp (a, name [I])! = 0) I ++; return I;} int main () {int n, num, p, q, I, j, topS, k; char a [100], B [100]; scanf ("% d", & n); while (n) {top = 0; for (I = 0; I <n; I ++) {indegree [I] = 0; for (j = 0; j <n; j ++) E [I] [j] = 0;} for (I = 0; I <n; I ++) {scanf ("% s", a, B); p = find (a); if (p = top) strcpy (name [top ++], a); q = find (B); if (q = top) strcpy (name [top ++], B ); E [p] [q] = 1; indegree [q] ++;} topS = 0; for (I = 0; I <n; I ++) if (indegree [I] = 0) Stack [topS ++] = I; k = topS; num = 0; while (topS) {I = Stack [-- topS]; num ++; for (j = 0; j <n; j ++) {if (E [I] [j] = 1) {indegree [j] --; if (indegree [j] = 0) Stack [topS ++] = j ;}} if (k = 1 & num = n) printf ("Yes \ n"); else printf ("No \ n"); scanf ("% d", & n );}}