當前位置:首頁 » 編程軟體 » 編程彩票

編程彩票

發布時間: 2022-07-24 15:41:47

㈠ vb編程彩票隨機問題

Private Sub Command1_Click()
Dim i, a(34), b(7)
Randomize: Cls
For i = 1 To 7
b(i) = Int(Rnd * 34 + 1)
If a(b(i)) Then i = i - 1 Else a(b(i)) = 1
Next
Print "34 選 7組 福利彩票系統,中獎號碼:"
For i = 1 To 7
Print b(i)
Next
End Sub

java如何編程福利彩票30選7,我自己編的但是不知道有什麼錯誤,希望幫我糾正一下,標注一下我的錯誤

你這個邏輯很混亂啊,數組a沒有初始化,i也不是全局變數。全局變數和局部變數用的很亂。這個程序不能用
public static void main(String[] args){
Random r=new Random();
for(i=0;i<7;i++){//i沒有初始化
a[i]=1+r.nextInt(30);//a[]沒有初始化
while(true)
{
panDuan(a[i]);
if(i==j) break;//j不是全局變數,這里不能用
}
}
Arrays.sort(a);//這里排序幹啥?七彩樂規則我不太懂
for(int k=0;k<7;k++){
System.out.print(a[k]+" ");}
}
private static void panDuan(int b) {
for(int j = 0;j<i;j++)
if(a[j]==b) break;//a[]不是全局變數,這里不能調用
// TODO Auto-generated method stub
}
}
你說下具體規則,我把程序寫好給你吧

㈢ vb編程,生成N組22選5的彩票號碼組(每組有不同的5個數字組成,且每個數碼只能取1~22之間的數)

1、首先打開「Microsoft Visual Basic 6.0 中文版」,選擇「標准 EXE」,並單擊「打開」按鈕,進入軟體界面。

c語言程序設計——彩票問題




以下的 C 小程序將輸出所有 28 個和值的出現的概率(輸出貼在程序下面)。
可見概率最高 0.075,最低 0.001,所以已開出的 1000 期彩票中出現頻率最高的和值是 13 和 14,
連續未出現期數最長的和值則是 0 和 27 (假設實際概率和理論概率吻合)。

#include<stdio.h>

/* 返回 number 中所有數字的和 */
unsigned sumOfAllDigits( unsigned number );

void main( ) {
/* 最低和值是 0,最高和值是 27,所以共有 28 個和值。*/
#define NUMBER_OF_SUM 28

unsigned chance[ NUMBER_OF_SUM ] = { 0 },
i;

for ( i = 0; i <= 999; i++ )
++chance[ sumOfAllDigits( i ) ];

puts( "和值\t出現的概率" );
puts( "一一\t一一一一一" );
for ( i = 0; i < NUMBER_OF_SUM; i++ )
printf( "%2u\t%.3f\n", i, chance[ i ] / 1000. );
}

unsigned sumOfAllDigits( unsigned number ) {
unsigned sum = 0;
for ( ; number; number /= 10 )
sum += number % 10;
return sum;
}

一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一

輸出:

和值出現的概率
一一一一一一一
00.001
10.003
20.006
30.010
40.015
50.021
60.028
70.036
80.045
90.055
100.063
110.069
120.073
130.075
140.075
150.073
160.069
170.063
180.055
190.045
200.036
210.028
220.021
230.015
240.010
250.006
260.003
270.001


㈤ C++編程:寫一個產生K組福彩M選N的機選彩票號碼程序(如K=5, M=35, N=7,表示機選5組35選7的號碼)。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

void selectsort(int *x, int n) {
int i, j, min,t;
for (i = 0; i < n - 1; i++) {
min = i;
for (j = i + 1; j < n; j++) {
if (*(x + j) < *(x + min)) min = j;
}
if (min != i) {
t = *(x + i);
*(x + i) = *(x + min);
*(x + min) = t;
}
}
}

void select(int m,int n,int k) {
int num[36],tmp[36],t;
char filename[] = "C:\\2011\\隨機號碼.txt"; // 選擇你需要的路徑
FILE *fp;
srand((unsigned)time(NULL));
fp = fopen(filename,"wt");
if(fp == NULL) {
printf("打開文件%s錯。\n",filename);
exit(1);
}
for(int i = 0;i < k;++i) {
for(int j = 1;j <= m;++j) tmp[j] = j;
for(j = 0;j < n;++j) {
t = (unsigned)rand()%m + 1;
if(tmp[t] != 0) {
num[j] = t;
tmp[t] = 0;
}
else --j;
}
selectsort(num,n);
for(j = 0;j < n;++j) {
fprintf(fp,"%02d ",num[j]);
printf("%02d ",num[j]);
}
fprintf(fp,"\n");
printf("\n");
}
fclose(fp);
}

int main() {
int m,n,k;
printf("被選號碼數 : ");
scanf("%d",&m);
printf("可選號碼數 : ");
scanf("%d",&n);
printf("所選組數 : ");
scanf("%d",&k);
select(m,n,k);
return 0;
}

㈥ 編寫程序生成一張彩票,彩票中包含7個1到36之間的隨機數(允許出現重復數字),最後把彩票的所有數字列印

我只發個核心代碼吧
for (int i1 = 1; i1 <= 36; i1++)
for (int i2 = 1; i2 <= 36; i2++)

for (int i3 = 1; i3 <= 36; i3++)

.....................................

for (int i7 = 1; i7 <= 36; i7++)

cout << i1 << " " << i2 << " " << ........<< i7 << endl;

你要枚舉所有情況,情況總數是36的7次方,所以運行時間很長,可能需要大約1分鍾。
並且所有情況都輸出到文件的話,輸出文件會很大

㈦ 3D彩票JAVA編程怎麼寫

importjava.util.ArrayList;importjava.util.List;importjava.util.Random;importjava.util.Scanner;publicclassLotto{publicstaticfinalintNUMBER=7;publicstaticvoidmain(String[]args){List<Integer>userNumbers=newArrayList<Integer>();Scannerscanner=newScanner(System.in);inti=1;while(i<8){System.out.println("輸入第"+i+"個數字:");userNumbers.add(scanner.nextInt());i++;}System.out.println(prize(userNumbers.toArray(newInteger[NUMBER])));}privatestaticInteger[]generateLotto(){List<Integer>lottoNumbers=newArrayList<Integer>();Randomrand=newRandom();intlottoNumber,i=0;while(i<NUMBER){lottoNumber=rand.nextInt(35)+1;if(!lottoNumbers.contains(lottoNumber)){lottoNumbers.add(lottoNumber);i++;}}returnbubbleSort(lottoNumbers.toArray(newInteger[NUMBER]));}privatestaticInteger[]bubbleSort(Integer[]array){for(inti=0;i<array.length;i++){for(intj=0;j<array.length-i-1;j++){if(array[j]>array[j+1]){inttemp=array[j+1];array[j+1]=array[j];array[j]=temp;}}}returnarray;}publicstaticStringprize(Integer[]userNumbers){intcount=0;Integer[]lottoNumbers=generateLotto();for(Integeri:userNumbers){for(Integerj:lottoNumbers){if(i==j){count++;}}}return"猜對了"+count+"個彩票號碼";}}
輸入第1個數字:
5
輸入第2個數字:
14
輸入第3個數字:
19
輸入第4個數字:
24
輸入第5個數字:
33
輸入第6個數字:
34
輸入第7個數字:
27
猜對了3個彩票號碼

㈧ VB彩票程序設計

新建一個單窗體的工程,在上面畫出七個TEXTBOX,最好是一個控制項數組,這樣編程時容易控制,再建一個COMMOND BUTTON,將CAPTION改為「隨機產生」。在程序運行後,每點擊一下COMMAND1,將隨機產生一組數字並按從小到大的順序顯示在文本框中。下面就是程序部分:Dim NumArray(1 To 7) As Integer′通用中定義
Private Sub Command1_Click()
Dim i, j, N As Integer
For i = 1 To 7
NumArray(i) = 0
Next i
Randomize
NumArray(1) = Fix(1 + 32 * (Rnd()))
j = 1
Do
N = Fix(1 + 32 * (Rnd()))
For i = 1 To j
If N = NumArray(i) Then
Exit For ′重復時
ElseIf i = j Then ′未重復時
NumArray(i + 1) = N
j = j + 1
Exit For
End If
Next i
Loop While j < 7
PopSort ′升序排列
For i = 1 To 7
Text1(i - 1).Text = NumArray(i)
Next i
End Sub
Private Sub PopSort() ′氣泡排序法
Dim i, j, Temp As Integer
For i = 7 To 2 Step -1
For j = 7 - 1 To 1 Step -1
If i >= 7 - j + 1 Then
If NumArray(j + 1) < NumArray(j) Then
Temp = NumArray(j)
NumArray(j) = NumArray(j + 1)
NumArray(j + 1) = Temp
End If
End If
Next j
Next i
End Sub

㈨ JAVA彩票編程:

package demo;import java.util.Random;public class Demo {
public static void main(String[] args) {
long x=0xfffL;
System.out.println(x);
Random r = new Random();
int a = (r.nextInt(33)+1);
int b = 0;
do{
b = r.nextInt(33)+1;
}while(b ==a);
int c = 0;
do{
c = r.nextInt(33)+1;
}while(c==a||c==b);
int d = 0;
do{
d = r.nextInt(33)+1;
}while(d==a||d==b||d==c);
int e = 0;
do{
e = r.nextInt(33)+1;
}while(e==a||e==b||e==c||e==d);
int f = 0;
do{
f = r.nextInt(33)+1;
}while(f==a||f==b||f==c||f==d||f==e);
int h = r.nextInt(16)+1;
System.out.println("紅球號碼:"+a+" "+b+" "+c+" "+d+" "+e+" "+f+" "+"藍球號碼:"+h);
}
}
//r.nextInt(33)+1 是產生1-33隨機數的 思想是先產生隨機數後判斷相等,有相等則繼續循環

㈩ 編寫買彩票程序。編程讓計算機隨機產生7個1~30的整數,要求每次產生的7

祝冊送宋rm比的 jjj.ee/rme7
static void Main(string[] args)
{
string i = null;
do
{
Console.Write("請輸入整數(范圍1~100)\n要退請輸入0否則輸入1");
i = Console.ReadLine();
if (i.Trim().Equals("0"))
{
return;
}
} while (!i.Trim().Equals("1"));
start:
Random ra = new Random();
int rndInt = ra.Next(1, 100);
int input = 0;
do
{
Console.Write("輸入猜數值:");
i = Console.ReadLine();
if (!int.TryParse(i, out input))
{
continue;
}
if (input > rndInt)
{
Console.Write("猜\n\n");
}
else if (input < rndInt)
{
Console.Write("猜\n\n");
}
} while (input != rndInt);
Console.Write("恭喜猜\n\n");
do
{
Console.Write("若繼續猜測輸入Y,若退則輸入N!\n請輸入:");
i = Console.ReadLine();
if (i.Trim().Equals("n", StringComparison.OrdinalIgnoreCase))
{
return;
}
if (i.Trim().Equals("y", StringComparison.OrdinalIgnoreCase))
{
goto start;
}
} while (!i.Trim().Equals("1"));
}

熱點內容
uc小說瀏覽器緩存 發布:2025-02-06 07:05:05 瀏覽:467
wifi路由手機怎麼設置密碼 發布:2025-02-06 07:00:57 瀏覽:985
nsurlsession上傳 發布:2025-02-06 06:55:18 瀏覽:336
亞洲十帥exo訪問 發布:2025-02-06 06:51:40 瀏覽:98
編程一首詩 發布:2025-02-06 06:45:04 瀏覽:528
驚聲尖笑5下載ftp 發布:2025-02-06 06:33:16 瀏覽:528
共享文件夾讓輸入密碼 發布:2025-02-06 06:32:28 瀏覽:970
收銀伺服器響應出錯什麼意思 發布:2025-02-06 06:24:43 瀏覽:607
sql用戶授權 發布:2025-02-06 06:24:42 瀏覽:677
蘋果手機相冊顯示正在上傳 發布:2025-02-06 06:05:43 瀏覽:542