LL今天心情特别好,因为他去买了一副扑克牌,发现里面居然有2个大王,2个小王(一副牌原本是54张^_^)...他随机从中抽出了5张牌,想测测自己的手气,看看能不能抽到顺子,如果抽到的话,他决定去买体育

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/chainiao_zhang/article/details/77618859
import java.util.*;//这种方法太暴力了public class Solution { public boolean isContinuous(int [] numbers) { int len=numbers.length; if(len!=5) return false; Arrays.sort(numbers); int m=0; for(int k=0;k<len;k++){ if(numbers[k]==0) { m++; } } if(m==0){ if(numbers[len-1]-numbers[0]==4){ return true; }else{ return false; } } if(m==1) { if(numbers[len-1]-numbers[1]==4||numbers[len-1]-numbers[1]==3){ return true; }else{ return false; } } if(m==2) { if(numbers[len-1]-numbers[2]==4||numbers[len-1]-numbers[2]==3||numbers[len-1]-numbers[2]==2){ return true; }else{ return false; } } if(m==3) { if(numbers[len-1]-numbers[3]==4||numbers[len-1]-numbers[3]==3||numbers[len-1]-numbers[3]==2||numbers[len-1]-numbers[3]==1){ return true; }else{ return false; } } if(m==4){ return true; } return false; }}
展开阅读全文

随机抽号设计问题】

03-06

[color=#FF0000]用的是Timer控件来刷新的。但是发现这个太占CPU了。多开几个就完蛋了。大家看看怎么处理。在不断的链接数据库。不是断开试么[/color]rn[code=C#] protected void Page_Load(object sender, EventArgs e)rn rnrnrn rn public void upload()rn rn int nu = 0;rn Random random = new Random();rn for (int i = 0; i < ListTest().Count; i++)rn rn nu = random.Next(ListTest().Count);rn this.Label1.Text = ListTest()[nu].ToString();rn rn rn public List ListTest()rn rn List list = new List();rn Tab_Random zhinan_class = (Tab_Random)Tab_RandomManager.Instance.GetModelTab_RandomByWhere("numid=0 order by newid()");rn list.Add(zhinan_class.Daqu);rn rn rn return list;rn rn protected void Button1_Click(object sender, EventArgs e)rn rnrn this.Timer1.Enabled = !this.Timer1.Enabled;rn Label2.Text = "".ToString();rnrn rnrnrn protected void Timer1_Tick(object sender, EventArgs e)rn rn upload();rn rn rnrn rnrn rn rn protected void asdasda_Click(object sender, EventArgs e)rn rn Tab_Random zhinan = (Tab_Random)Tab_RandomManager.Instance.GetModelTab_RandomByWhere("daqu='" + Label1.Text.ToString() + "'");rn string dadada = zhinan.Daqu.ToString();rnrnrn AnswerDAL.Intance.ModifyTab_Random(dadada);rn rn protected void Button2_Click(object sender, EventArgs e)rn rn AnswerDAL.Intance.ModifyTab_RandomAll();rn rnrnrnrnrnrn protected void Timer2_Tick(object sender, EventArgs e)rn rn uploadone();rn rnrn public void uploadone()rn rn int nu = 0;rn Random random = new Random();rn for (int i = 0; i < ListTest().Count; i++)rn rn nu = random.Next(ListTest().Count);rn this.Label2.Text = ListTestone()[nu].ToString();rn rn rn rnrn public List ListTestone()rn rn List list = new List();rn Tab_Random zhinan_class = (Tab_Random)Tab_RandomManager.Instance.GetModelTab_RandomByWhere("numid=0 and daqu='" + Label1.Text .ToString()+ "' order by newid()");rn list.Add(zhinan_class.Name);rn return list;rn rn[/code] 论坛

没有更多推荐了,返回首页