using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;
using System.IO;
namespace ccs_getchar
{
class Program
{
static void Main(string[] args)
{
for (int n = 0; n < 6; n++)
{
Console.WriteLine();
Console.WriteLine("please input the chinese character:");
string chinese = Console.ReadLine();
string path = @"c:\asd\gbcdbig.txt";
string[] strNew;
int cctarget = 0;
ArrayList cc = new ArrayList();
string[] contents = File.ReadAllLines(path, Encoding.Default);
string flag = Convert.ToString('*');
for (int i = 0; i < contents.Length; i++)
{
strNew = contents[i].Split(new char[1] { ' ' }); //strNew.Indexof
// Console.WriteLine(contents[i]);
for (int m = 0; m < strNew.Length; m++)
{
if (strNew[m] == chinese)
{
if (cctarget == 0)
{
for (int j = 0; j < strNew.Length; j++)
{
cc.Add(strNew[j]);
}
cctarget = cctarget + 1;
break;
}
}
else if (cctarget == 1)
{
if (strNew[m] != flag)
{
for (int j = 0; j < strNew.Length; j++)
{
cc.Add(strNew[j]);
}
}
else
cctarget = cctarget + 1;
break;
}
else if (cctarget == 2)
break;
}
}
cc.RemoveRange(0, 4);
string[] rd_pos = (string[])cc.ToArray(typeof(string));
int[] pos_int = new int[rd_pos.Length];
for (int i = 0; i < rd_pos.Length; i++)
{
int.TryParse(rd_pos[i], out pos_int[i]);
}
foreach (var item in pos_int)
{
Console.Write(item + " ");
}
Console.ReadKey();
}
}
}
}
TXT的文件格式如下