NEU1003 you are my brother 自己乱七八糟的代码和大神级的比较

 1 所谓算法,总有妙处!自己当折服,当改进 ,当有灵感,当创新,当学习,无止境!@@
 2 
比如/*#include<stdio.h>
 4 struct people
 5 {
 6     int x,y;
 7 };
 8 int compare(struct people x[1010],int num)
 9 {
10     int count1=0,count2=0,i,j;
11     for(i=1;i<num;i++)
12         for(j=i+1;j<num;j++)
13         {
14             if(x[j].y==x[i].x)
15             {
16                 count1++;
17             }
18         }
19     for(i=0;i<num;i++)
20          for(j=i+1;j<num;j++)
21          {
22              if(x[j].y==x[i].x)
23              {
24                  count2++;
25              }
26          }
27     if(count1>count2) return 1;
28     if(count1<count2) return 2;
29     if(count1==count2) return 3;
30 
31 }
32 int main()
33 {
34     freopen("input1.txt","r",stdin);
35     freopen("output2.txt","w",stdout);
36     int num;
37     while(scanf("%d",&num)!=EOF)
38     {
39         int i,count1=0,count2=0;
40         struct people child[1010];
41         for(i=0;i<num;i++)
42         {
43             scanf("%d%d",&child[i].x,&child[i].y);
44         }
45        if((compare(child,num))==1) printf("1");
46        if((compare(child,num))==2) printf("2");
47        if((compare(child,num))==3) printf("3");
48 
49     }
50     return 0;
51 }*/
52 
53 #include <stdio.h>
54 int main()
55 {
56  
57 
58 int n,i,j,k;
59  int la,lb,a,b;
60  while(scanf("%d",&n)!=EOF)
61  {
62     la=1;lb=2;a=0;b=0;
63   for(k=0;k<n;++k)
64   {
65      scanf("%d%d",&i,&j);
66      if(la!=lb)
67      {
68                if(i==la)
69                {
70                    la=j;
71                    a++;
72                }
73                if(i==lb)
74                {
75                    lb=j;
76                    b++;
77                }
78      }
79   }
80   if(a<b)
81            printf("You are my younger\n");
82        else if(a==b)
83            printf("You are my brother\n");
84        else if(a>b)
85            printf("You are my elder\n");
86  }
87  return 0;
88 }
89 
90 you know?????

 

posted @ 2013-02-16 18:05  闭关修炼的小孩纸  阅读(93)  评论(0编辑  收藏  举报