前端之家收集整理的这篇文章主要介绍了
[VB.NET]晕倒,还是有重复的数字,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
晕倒,还是有重复的数字 Dim r As New Random While i < 27 Dim j As Int32 = r.Next(0,54) i = i + 1 txt2.Text = txt2.Text & j & "_ " lba.Text = lba.Text & j & "," End While txt2.Text:12_33_50_43_31_16_12_46_47_25_47_8_19_33_51_35_13_21_12_7_19_39_34_44_15_42_4_ 12重复了,47重复了 晕呼,怎么样才能不重复呢 在0-53 里找出27个不重复的 做一个扑克的小小游戏 想用一个二维数组存放牌 第一维放牌,第二维放是给谁的(a,b两个人) 所以要先提出来27个重复的数,老是有重复的呢? __________________________________________________________________________ 晕,又着急了!!!!!!!! 这个问题有点赶,又忘了给分了,下一次一定双倍的补回来!!!!!!!! __________________________________________________________________________ 恩.....还是没弄出来 __________________________________________________________________________ Dim r As New Random() '' '' '' '' ''System.Random a= new Random(); for(int i=0;i <=5;i++) { string j; j=a.Next(0,100).ToString(); Console.Write( " " +j); } While i < 27 ''Dim r As New Random(System.DateTime.Now.Millisecond + i) Dim j2 As Int32 = r.Next(0,53) i = i + 1 txt2.Text = txt2.Text & j2 & "_ " lbb.Text = lbb.Text & j2 & "," End While 算出来的有重复的 这个弄不出来,我这个东西就走不出去第一步 还请多指点!!! 顺便问下,为什么我在提问的时候给分那里没有分 20分都说我给的分高? __________________________________________________________________________ 可能您的可用分没了吧,我上网的帐号里没钱了,我先充值去,呵呵。 __________________________________________________________________________ Private Sub Form1_Load(ByVal sender As Object,ByVal e As System.EventArgs) Handles Me.Load Dim r As New Random Dim i As Int32 = 0 While i < 27 Dim j As Int32 = r.Next(0,54) '' 检查是否有重复的,若有则不加入txt2.Text,而继续
生成下一个
随机数 If Not txt2.Text.Contains(j) Then txt2.Text = txt2.Text & j & "_ " lba.Text = lba.Text & j & "," i += 1 End If End While End Sub __________________________________________________________________________ 谢谢楼上的!!!! 题外话:那我怎么给问题加分呢?? __________________________________________________________________________ 没办法了,或者等你有了分在给我吧,呵呵。有你一句谢谢也可以了。 __________________________________________________________________________ 您在北京么? __________________________________________________________________________
原文链接:https://www.f2er.com/vb/263797.html