110,536
社区成员
发帖
与我相关
我的任务
分享
List<string> list = new List<string>() {
"*???",
"*MLC?-??",
"*MLCQ-??",
"*MLCQ?1346?+",
"*MLCQ?13463-?????",
"*MLCQ-13463-1206?",
"*MLCQ-13463-120627-??/",
"*MLCQ-13463-120627-001?",
"*?LCQ-?3463-120627-0?1*",
"*MLCQ-?3463-1?0627-001*",
"*MLCQ-?3463-1?0627-001*",
"*MLCQ-?3463-1?0627-001*",
"*MLCQ-?3463-1?0?27-00??",
"*MLCQ-?3463-1?0627-001?",
"*MLCQ-?3463-1?0627-001?",
"*MLCQ-?3463-1?06?7-00??",
"*MLCQ-?3463-1?06?7-001?",
"*ML?Q-??46?-1?06?7-001?",
"*MLCQ-13463-1?0627-00??",
"*MLCQ-13463-1?0627-00??",
"*MLCQ-?346?-1?06??-00??",
"*ML?Q-??46?-??06?7-001?",
"*ML?Q-1346?-1?06?7-001?",
"*ML?Q-1346?-1?06?7-00??",
"*ML?Q-??463-1?06??-00??",
"*ML?Q-1?463-1?06?7-001?",
"*ML?Q-1?463-1?06?7-001?",
"*?Z??",
"*ML?Q-1?463-1?06?7-001?",
"*M??Q-??46?-1?06??-00??",
"*ML?Q-13463-1?06??-0???",
"*ML?Q-13463-1?06??-0???",
"*M??Q-?3463-1?06??-00?*",
"*ML?Q-13463-1?06??-001*",
"*M??Q-13463-1?06??-001*",
"*M??Q-13463-1?06??-001*",
"*M????13463-1?06??-0?1*",
"*M??Q?13463-1206??-0?1?",
"*M?CQ?13463-1206??-001*",
"*MLCQ?13463-1206??-001*",
"*MLC??13463-1206??-001*",
"*M?CQ?13463-12062?-001*",
"*MLCQ?13463-12062?-001*",
"*MLCQ?13463-12062?-001*",
"*MLCQ-13463-1206??-001*",
"*MLCQ-13463-12062?-001*"
};
StringBuilder sb = new StringBuilder();
int column_count = list.Max(a => a.Length);
string[] temp_arr = new string[column_count];
for (int j = 0; j < list.Count(); j++)
{
for (int k = 0; k < list[j].Length; k++)
{
temp_arr[k] += list[j][k];
}
}
foreach (string item in temp_arr)
{
var temp=item.ToCharArray().Where(a=>a!='?').GroupBy(a => a).OrderByDescending(a=>a.Count()).FirstOrDefault();
if (temp != null)
{
sb.Append(temp.Key.ToString());
}
else
{
sb.Append("?");
}
}
string result = sb.ToString();
//*MLCQ-13463-120627-001*
System.IO.StreamReader reader = new System.IO.StreamReader("e:\\1.txt");
//下面对数据进行处理,分离出4个list
List<string>[] list = new List<string>[4];
list[0] = new List<string>();
list[1] = new List<string>();
list[2] = new List<string>();
list[3] = new List<string>();
while (!reader.EndOfStream)
{
string[] s = reader.ReadLine().Split('-');
for (int i = 0; i < s.Length; i++)
{
list[i].Add(s[i]);
}
}
var vs = list[0].GroupBy(x => x).Select(g => new { g.Key, count = g.Count() }).Where(w => w.Key.Contains("?") == false).Max(c => c.Key) + "-" +
list[1].GroupBy(x => x).Select(g => new { g.Key, count = g.Count() }).Where(w => w.Key.Contains("?") == false).Max(c => c.Key) + "-" +
list[2].GroupBy(x => x).Select(g => new { g.Key, count = g.Count() }).Where(w => w.Key.Contains("?") == false).Max(c => c.Key) + "-" +
list[3].GroupBy(x => x).Select(g => new { g.Key, count = g.Count() }).Where(w => w.Key.Contains("?") == false).Max(c => c.Key);
MessageBox.Show(vs.ToString());
string result=list.GroupBy(a => a).OrderByDescending(a => a.Count()).FirstOrDefault().Key.Replace("?",string.Empty);
//*MLCQ-3463-10627-001*