public string B(statya p) { int i = -1; int n = 0; for (int j = 0; j < vectors.Length; j++) { int max = 0; foreach (string k in p.analiz_vector.Keys) { if (vectors[j].values.ContainsKey(k)) max++; } if (max > n) { n = max; i = j; } } if (i > -1) return vectors[i].name; else return "Error"; }
static void Main(string[] args) { statya p1 = new statya("n1.txt"); statya p2 = new statya("n2.txt"); statya p3 = new statya("n3.txt"); statya p21 = new statya("s1.txt"); statya p22 = new statya("s2.txt"); statya p23 = new statya("s3.txt"); vector v1 = new vector("наука"); v1.add(p1); v1.add(p2); v1.add(p3); vector v2 = new vector("sport"); v2.add(p21); v2.add(p22); v2.add(p23); perevirka a = new perevirka(new vector[] { v1, v2 }); statya t1 = new statya("t1.txt"); statya t2 = new statya("t2.txt"); Console.WriteLine(a.B(t1)); Console.WriteLine(a.B(t2)); }
public void add(statya p) { Dictionary<string, double> add_list = p.analiz_vector; if (values == null) { values = add_list; } else { foreach (string a in add_list.Keys) { if (values.ContainsKey(a)) { values[a] = (values[a] + add_list[a]) / 2; } else { values.Add(a, add_list[a]); } } } }