注册 登录
编程论坛 C# 论坛

谁能帮忙翻成C语言

chaw899 发布于 2019-01-09 15:46, 2131 次点击
解析sgf棋谱

(;CA[gb2312]SZ[19]AP[MultiGo:4.4.4]MULTIGOGM[1]
;B[qd];W[dp];B[dc];W[ce];B[pq];W[qo];B[pl];W[oc];

解析成r16,d4,d17,c15,q3,r5......

把下面的代码翻译一成C语言,谢谢!

private void Window_Loaded(object sender, RoutedEventArgs e)
{

SGFFile.Text = sgf_string = File.ReadAllText("1.sgf");
}

private void Button_Click(object sender, RoutedEventArgs e)
{
string[] lines = sgf_string.Split(';') ;
foreach (var i in lines)
{
if(i.StartsWith("B") || i.StartsWith("W") )
{
string a = i.Substring(2).Remove(2);
string x = a.Remove(1);
if(System.Text.Encoding.ASCII.GetBytes(x)[0]> System.Text.Encoding.ASCII.GetBytes

("l")[0])
{
byte[] array = new byte[1];
array[0] = (byte)(Convert.ToInt32(System.Text.Encoding.ASCII.GetBytes(x)[0] 1));
x = Convert.ToString(System.Text.Encoding.ASCII.GetString(array));
}
string y = a.Substring(1);
y = (System.Text.Encoding.ASCII.GetBytes("s")[0] -

System.Text.Encoding.ASCII.GetBytes(y)[0] 1).ToString();

decode = decode x y ",";
}

}
decode = decode.Remove(decode.Length-1,1);

SGFDecode.Text = decode;
}
}
1 回复
#2
xiaoge1232019-01-11 10:00
有一个java to C# 的网站,就是翻译的时候会有一些问题,自己看着再改下
http://www.
1