MemoryGarden's Blog

努力 -----------大能猫

C++博客 首页 新随笔 联系 聚合 管理
  118 Posts :: 11 Stories :: 20 Comments :: 0 Trackbacks

acm user pk 器,嘿嘿, c#编写。bug很多,大家凑和用

http://www.cppblog.com/Files/MemoryGarden/CMP.rar


主要的People 类如下:  水水的代码,希望大牛指教。


  1 using System;
  2 using System.Collections.Generic;
  3 using System.Text;
  4 using System.Windows.Forms;
  5 using System.Collections;
  6 namespace CMP
  7 {
  8     class People
  9     {
 10         public int[] soveld = new int[10000];
 11         public int[] failed = new int[10000];
 12         public int sovelength, failedlength;
 13         public int los = 0, lof = 0, lbs = 0, lbf = 0, rl = 0;
 14         public People(string a, string b)
 15         {
 16             this.sovelength = this.failedlength = 0;
 17             char[] aa = a.ToCharArray();
 18             char[] bb = b.ToCharArray();
 19             char[] t = new char[1000];
 20             int laa = a.Length;
 21             int lbb = b.Length, tlength = 0, sum = 0;
 22             int i, j, k;
 23             for (i = 0; i < laa; i++)
 24             {
 25                 if (aa[i] != ' ' && aa[i] != '\n')
 26                     t[tlength++= aa[i];
 27                 else
 28                 {
 29                     if (tlength != 0)
 30                     {
 31                         sum = 0;
 32                         for (j = tlength - 1, k = 1; j >= 0; j--, k *= 10)
 33                             sum += (t[j] - '0'* k;
 34                         this.soveld[this.sovelength++= sum;
 35                     }
 36                     tlength = 0;
 37                 }
 38             }
 39             if (tlength != 0)
 40             {
 41                 sum = 0;
 42                 for (j = tlength - 1, k = 1; j >= 0; j--, k *= 10)
 43                     sum += (t[j] - '0'* k;
 44                 this.soveld[this.sovelength++= sum;
 45             }
 46             tlength = sum = 0;
 47             for (i = 0; i < lbb; i++)
 48             {
 49                 if (bb[i] != ' ' && bb[i] != '\n')
 50                     t[tlength++= bb[i];
 51                 else
 52                 {
 53                     if (tlength != 0)
 54                     {
 55                         sum = 0;
 56                         for (j = tlength - 1, k = 1; j >= 0; j--, k *= 10)
 57                             sum += (t[j] - '0'* k;
 58                         this.failed[this.failedlength++= sum;
 59                     }
 60                     tlength = 0;
 61                 }
 62             }
 63             if (tlength != 0)
 64             {
 65                 sum = 0;
 66                 for (j = tlength - 1, k = 1; j >= 0; j--, k *= 10)
 67                     sum += (t[j] - '0'* k;
 68                 this.failed[this.failedlength++= sum;
 69             }
 70         }
 71 
 72         public int[] OnlySoved(People CmpPeople)
 73         {
 74             int i, j, reslength = 0, ok;
 75             int[] res = new int[1000];
 76             for (i = 0; i < this.sovelength; i++)
 77             {
 78                 ok = 0;
 79                 for (j = 0; j < CmpPeople.sovelength; j++)
 80                 {
 81                     if (this.soveld[i] == CmpPeople.soveld[j])
 82                     {
 83                         ok = 1;
 84                         break;
 85                     }
 86                 }
 87                 if (ok == 0)
 88                 {
 89                     res[reslength++= this.soveld[i];
 90                 }
 91             }
 92             los = reslength;
 93             return res;
 94         }
 95 
 96         public int[] OnlyFailed(People CmpPeople)
 97         {
 98             int i, j, reslength = 0, ok;
 99             int[] res = new int[1000];
100             for (i = 0; i < this.failedlength; i++)
101             {
102                 ok = 0;
103                 for (j = 0; j < CmpPeople.failedlength; j++)
104                 {
105                     if (this.failed[i] == CmpPeople.failed[j])
106                     {
107                         ok = 1;
108                         break;
109                     }
110                 }
111                 if (ok == 0)
112                 {
113                     res[reslength++= this.failed[i];
114                 }
115             }
116             lof = reslength;
117             return res;
118         }
119 
120 
121         
122         public int[] BothSoved(People CmpPeople)
123         {
124             int i, j, reslength = 0;
125             int[] res = new int[1000];
126             for (i = 0; i < this.sovelength; i++)
127             {
128                 for (j = 0; j < CmpPeople.sovelength; j++)
129                 {
130                     if (this.soveld[i] == CmpPeople.soveld[j])
131                     {
132                         res[reslength++= this.soveld[i];
133                         break;
134                     }
135                 }
136             }
137             lbs = reslength;
138             return res;
139         }
140         public int[] BothFailed(People CmpPeople)
141         {
142             int i, j, reslength = 0;
143             int[] res = new int[1000];
144             for (i = 0; i < this.failedlength; i++)
145             {
146                 for (j = 0; j < CmpPeople.failedlength; j++)
147                 {
148                     if (this.failed[i] == CmpPeople.failed[j])
149                     {
150                         res[reslength++= this.failed[i];
151                         break;
152                     }
153                 }
154             }
155             lbf = reslength;
156             return res;
157         }
158 
159         public int[] Red(People CmpPeople)
160         {
161             int i, j, reslength = 0;
162             int[] res = new int[1000];
163             for (i = 0; i < this.sovelength; i++)
164             {
165                 for (j = 0; j < CmpPeople.failedlength; j++)
166                 {
167                     if (this.soveld[i] == CmpPeople.failed[j])
168                     {
169                         res[reslength++= this.soveld[i];
170                         break;
171                     }
172                 }
173             }
174             rl = reslength;
175             return res;
176         }
177 
178     }
179 }
180 

posted on 2008-09-30 21:52 memorygarden 阅读(133) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理