三九宝宝网宝宝教育教学论文

VB的猜数小游戏

02月27日 编辑 39baobao.com

[c语言简单猜数游戏急]#include <stdio.h> #include<stdlib.h> #include <time.h> main() { int a,b,i=1; srand((unsigned)time(NULL));//产生随机数种子 a=rand()%100+1;//产生随机数 printf("\ \\t...+阅读

这是界面布局,当然,你可以弄好看一些!

代码如下:

Dim i As Integer, j As Integer Private Sub Timer1_Timer() i = Val(Rnd * 100) + 1 j = Val(Rnd * 100) + 1 Text1.Text = Str(i) Text2.Text = Str(j) End Sub Private Sub Command1_Click() Timer1.Enabled = False If i < j Then Text3.Text = "很遗憾,你猜错了" Else Text3.Text = "恭喜,你猜对了" End If End Sub Private Sub Command2_Click() Timer1.Enabled = True Timer1.Interval = 10 Text1.Visible = True'滚动显示 Text2.Visible = True'同上 Text3.Text = "" End Sub Private Sub Command3_Click() Timer1.Enabled = False If i > j Then Text3.Text = "很遗憾,你猜错了" Else Text3.Text = "恭喜,你猜对了" End If End Sub

用VB编写一个小游戏

如果要做1-52的牌的话,建议这么来,1-4是1,5-8是2……以此类推,37-40是10吧,应该不是45吧?这种情况下,只要将牌的序号整除4,然后+1得到的结果就是拍的数值了,比如9/4+1=3,这张牌是3,再假设1是黑桃,2是红桃,3是梅花,4是方块,那么将牌的序号对4去模,就能得到牌对应的花色,比如9MOD4=1,那么这张牌的花色就是黑桃。加牌的方法很简单,你讲1-52张排做一个数组,,里面填充的值是1-52每次抽牌都是一个1-52的随机数(要无限循环,直到取到牌才break出来),比如取到了33号牌,那么就标记一下33号的数字为0,这样你下次再随机抽中33的时候判断一下他的数值是不是0就能知道这张牌是不是被抽走了。...

希望提供一个vb编写的小游戏不要那些五子棋贪吃蛇之类的最

习题 1。抽奖的啊 Private Sub Command1_Click() Timer1.Enabled = True End Sub Private Sub Command2_Click() Timer1.Enabled = False End Sub Private Sub Form_Load() For I = 0 To 5 Label1(I).FontSize = 48 Next I Timer1.Enabled = False End Sub Private Sub Timer1_Timer() Randomize For I = 0 To 5 Randomize Label1(I).Caption = Int(Rnd() * 10) Next I End Sub 2.计算机 Dim w1 Dim w2 Dim S Dim t1 Dim t2 Dim t3 Dim w3 Dim t4 Private Sub Command1_Click() Text1 = Text1 & Command1.Caption End Sub Private Sub Command10_Click() Text1 = Text1 & Command10.Caption End Sub Private Sub Command11_Click() S = S + Val(Text1) Text1 = "" t1 = True t2 = False t3 = False t4 = False End Sub Private Sub Command12_Click() If w1 = False Then S = Val(Text1) w1 = True S = S - Val(Text1) Text1 = "" t1 = False t2 = True t3 = False t4 = False Else S = S - Val(Text1) Text1 = "" t1 = False t2 = True t3 = False t4 = False End If End Sub Private Sub Command13_Click() If w3 = False Then S = Val(Text1) w3 = True Text1 = "" t1 = False t2 = False t3 = True t4 = False Else S = S * Val(Text1) Text1 = "" t1 = False t2 = False t3 = True t4 = False End If End Sub Private Sub Command14_Click() If w2 = False Then S = Val(Text1) w2 = True Text1 = "" t1 = False t2 = False t3 = False t4 = True Else S = S / Val(Text1) Text1 = "" t1 = False t2 = False t3 = False t4 = True End If End Sub Private Sub Command15_Click() S = Sqr(S) Text1 = Str(S) End Sub Private Sub Command16_Click() w1 = False w2 = False w3 = False Command16.Caption = "复位" S = 0 Text1 = "" End Sub Private Sub Command17_Click() If t1 = True Then S = S + Val(Text1) Text1 = Str(S) ElseIf t2 = True Then S = S - Val(Text1) Text1 = Str(S) ElseIf t3 = True Then S = S * Val(Text1) Text1 = Str(S) Else S = S / Val(Text1) Text1 = Str(S) End If End Sub Private Sub Command2_Click() Text1 = Text1 & Command2.Caption End Sub Private Sub Command3_Click() Text1 = Text1 & Command3.Caption End Sub Private Sub Command4_Click() Text1 = Text1 & Command4.Caption End Sub Private Sub Command5_Click() Text1 = Text1 & Command5.Caption End Sub Private Sub Command6_Click() Text1 = Text1 & Command6.Caption End Sub Private Sub Command7_Click() Text1 = Text1 & Command7.Caption End Sub Private Sub Command8_Click() Text1 = Text1 & Command8.Caption End Sub Private Sub Command9_Click() Text1 = Text1 & Command9.Caption End Sub Private Sub Form_Load() t1 = False t2 = False t3 = False t4 = False t6 = False t7 = False End Sub 3。

打方块小游戏 注意timer1和timer2开始时ENABLED属性设置为FALSE Private Sub Command1_Click() Timer1.Interval = 900 End Sub Private Sub Command2_Click() Timer1.Interval = 600 End Sub Private Sub Command3_Click() Timer1.Interval = 500 End Sub Private Sub Command4_Click() Timer2.Enabled = True Timer1.Enabled = True Command1.Enabled = True Command2.Enabled = True Command3.Enabled = True Command5.Visible = True Timer2.Interval = 1000 End Sub Private Sub Command5_Click() Static r r = r + 1 Text2 = Str(r) End Sub Private Sub Timer1_Timer() Randomize a = Int(Rnd() * 255) b = Int(Rnd() * 255) c = Int(Rnd() * 255) d = Int(Rnd() * 9495) e = Int(Rnd() * 10935) Command5.BackColor = RGB(a, b, c) Command5.Move d, e End Sub Private Sub Timer2_Timer() Static i i = i + 1 Text1 = Str(30 - i) If i = 30 Then Timer1.Enabled = False Timer2.Enabled = False Command5.Visible = False i = 0 r = 0 End If End Sub

以下为关联文档:

用c语言编写一个猜数游戏#include <stdio.h> #include <stdlib.h> #include <time.h> #define Range 100 int guess(int k){ int input; printf("请输入数字:\t"); scanf("%d",&input); if(input==k)return...

求C语言编写的猜数字游戏程序#include<iostream> using namespace std; int main() { char s[88],r[88]; printf(" 本游戏只能猜8次!!\n请输入游戏四位不重复的数字\n"); scanf("%s",s); if(strlen(s)!=4)exit(1...

用C语言编写猜数游戏原发布者:阿波爱喝水 注意本程序使用rand函数此函数在此程序中默认随机值为1275可以用来测试程序#include#includeintmain(void){intc,r,s,x,y,m=0,n=0;inta[4],b[4];do{x=ra...

c语言程序设计猜数游戏//在TC下运行 #include"stdio.h" #include"stdlib.h" void main() { int i,j,n=0; i=random(100); do{ printf("请输入你猜的数字\n"); scanf("%d",&j); if(j<i) printf("Your answer i...

用C语言编写一个具有简单界面的猜数字游戏分析: 先产生一个随机数N。 然后输入数I,如果i大于N,则提示大于信息。 如果I小于N,则提示小于信息。 直到I==N,则输出成功信息。 这是我用C语言写的。 环境: WIN-C ,TORBO C,如果是...

求C语言程序猜数游戏/*十次不太合理,每次取中间数猜的话,七次就猜中了,所以设了六次*/ #include <stdio.h> #include <stdlib.h> #include <time.h> main() { int n,N,i,j; printf("游戏提示:黑暗中有...

C语言编程猜数游戏#include <stdio.h> #include <stdlib.h> #include <time.h> void main() { int a; srand(time(NULL)); a=rand()%101; int n,count=0; printf("input the number you want g...

猜数游戏 C语言程序设计//猜1-100的随机数,有大小提示,并给出回答次数和所用时间的统计。 #include <stdio.h> #include <stdlib.h> #include <time.h> void main() { int i,g,j=1; long t; srand((u...

急求!用C语言编写099之间的猜数游戏内容:设计一个猜数字游戏,它能根据游戏规则猜数。 功能:产生原始数字:产生4个随机数,并按任意顺序排列。 游戏提示:用1A2B形式提示玩家当前猜数字的匹配情况。例如1A表示玩家猜测...

推荐阅读
图文推荐