按照题目要求编写的Python程序如下
import random
numlist=random.sample(range(0,10),5)
while numlist[0]==0:
numlist=random.sample(range(0,10),5)
num=int(''.join([str(i) for i in numlist]))
inputnum=int(input("输入号:"))
bonus=0
count=0
if inputnum==num:
bonus=10000
else:
for i in set(str(inputnum)):
if int(i) in numlist:
count+=1
bonus=1000*count
print("彩票号:%d" % num)
print("奖金:%d元" % bonus)
源代码(注意源代码的缩进)
祝册送宋rm比的 jjj.ee/rme7static 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"))
}
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
请不要发违规广告,是违法行为
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)