110,537
社区成员
发帖
与我相关
我的任务
分享
private void Win(object obj, EventArgs e)
{
isFinished = mineMatrix.IsFinished;
timer1.Stop();
mp.DrawFace(Face.Glasses);
mp.IsWin = true;
if (Properties.Settings.Default.soundEnable)
{
System.Media.SoundPlayer sp = new System.Media.SoundPlayer(Properties.Resources.Win);
sp.Play();
}
Properties.Settings.Default.Save();
string strConnection = "Server=(local);Database=Mine;uid=sa;pwd=netbox123*;initial catalog=Mine;Server=(local); Connect Timeout=30;";
SqlConnection objConnection = new SqlConnection(strConnection);
string sql = "insert into Count(result) values('1');";
SqlCommand Count = new SqlCommand(sql, objConnection);
objConnection.Open();
int 受影响行数 = Count.ExecuteNonQuery();
Console.WriteLine("{0}行受影响", 受影响行数);
Console.Read();
}
-- 胜率
select 胜率 = substring(cast((cast (a.胜场数 as decimal)/cast(b.场数 as decimal) * 100) as varchar),1,5) + '%'
from
(select count(1) as 胜场数 from count where result = 1) a
left join
(select count(1) as 场数 from count) b
on 1 = 1
-- 当前状态,有可能连胜有可能连负
select top 1 连续场数 = max(num1) - min(num1) + 1,胜负 = result from (
select num1 = id - 0,num2 = (select count(1) from count where id <= t.id and result = t.result),*
from count t
where t.result in (select top 1 result from count order by id desc)
) t group by t.num1 - t.num2,result order by t.num1 - t.num2 desc
select result from table order by id desc
List<int> list = new List<int>();
var 连续数 = list.TakeWhile(i => i != list[0]);//根据List[0]是0还是1来确认是连续胜,还是连续败
var 胜率 = Math.Round(list.Count(i => i == 1) * 1.0 / list.Count, 3);
-- 最大连胜
select 最大连胜 = max(连胜) from (
select 连胜 = max(num1) - min(num1) + 1 from (
select num1 = id - 0,num2 = (select count(1) from count where id <= t.id and result = 1),* from count t where result = 1
) t group by t.num1 - t.num2
) t
-- 最大连负
-- 将最大连胜里面的两个地方的result = 1改为result = 0即可
-- 已玩局数
select count(1) from Count