VB编程年会抽奖代码?

VB编程年会抽奖代码?,第1张

语言实现此程序。

以下是VB编程语言的实现示例:

'定义变量,存储每个奖项的人数

Dim firstPrize As Integer = 3

Dim secondPrize As Integer = 5

Dim thirdPrize As Integer = 12

Dim souvenirPrize As Integer = 10

'定义变量,存储抽奖结果

Dim firstPrizeList As New List(Of Integer)

Dim secondPrizeList As New List(Of Integer)

Dim thirdPrizeList As New List(Of Integer)

Dim souvenirPrizeList As New List(Of Integer)

'定义变量,存储编号滚动的起始编号

Dim currentNum As Integer = 1

'循环抽取各种奖项

For i As Integer = 1 To firstPrize

'抽取一等奖,并将编号添加到一等奖名单

firstPrizeList.Add(currentNum)

currentNum += 1

Next

For i As Integer = 1 To secondPrize

'抽取二等奖,并将编号添加到二等奖名单中

secondPrizeList.Add(currentNum)

currentNum += 1

Next

For i As Integer = 1 To thirdPrize

'抽取三等奖,并将编号添加到三等奖名单中

thirdPrizeList.Add(currentNum)

currentNum += 1

Next

For i As Integer = 1 To souvenirPrize

'抽取纪念奖,并将编号添加到纪念奖名单中

souvenirPrizeList.Add(currentNum)

currentNum += 1

Next

'输出抽奖结果

Console.WriteLine("一等奖名单:" &String.Join(",", firstPrizeList))

Console.WriteLine("二等奖名单:" &String.Join(",", secondPrizeList))

Console.WriteLine("三等奖名单:" &String.Join(",", thirdPrizeList))

Console.WriteLine("纪念奖名单:" &String.Join(",", souvenirPrizeList))

import java.util.Scanner

/**

 *

 */

public class f {

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in)

        System.out.print("请输入抽奖号码上限:")

        int max = scan.nextInt()

        System.out.print("请输入抽奖次数:")

        int n = scan.nextInt()

        System.out.print("中奖号码依次为:")

        for(int i=0i<ni++){

            System.out.print((int)(Math.random()*max+1)+" ")

        }

    }

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12130222.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存