1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int compair(char a[],char b[]); 6 int n,i,j,t,frist; 7 struct 8 { 9 char a[100]; 10 char b[100]; 11 } grade[1000]; 12 while(~scanf("%d",&n)&&n) 13 { 14 memset(grade,0,sizeof grade); 15 for(i=0; i<n; ++i) 16 scanf("%s%s",grade[i].a,grade[i].b); 17 for(i=t=0; i<n; ++i) 18 { 19 for(j=0; j<n; ++j) 20 if(compair(grade[i].a,grade[j].b)) 21 break; 22 if(j==n) 23 if(t) 24 { 25 if(!compair(grade[frist].a,grade[i].a)) 26 ++t; 27 } 28 else 29 { 30 frist=i; 31 ++t; 32 } 33 //printf("t=%d\n",t); 34 if(t>1) 35 { 36 printf("No\n"); 37 break; 38 } 39 } 40 if(t==1) 41 printf("Yes\n"); 42 else if(t<1) 43 printf("No\n"); 44 } 45 } 46 47 int compair(char a[],char b[]) 48 { 49 int i; 50 for(i=0; a[i]!=‘\0‘&&b[i]!=‘\0‘; ++i) 51 if(a[i]!=b[i]) 52 { 53 return 0; 54 break; 55 } 56 if(a[i]!=‘\0‘||b[i]!=‘\0‘) 57 return 0; 58 else 59 return 1; 60 }
时间: 2024-11-07 15:09:57