返學(xué)費(fèi)網(wǎng) > 培訓(xùn)機(jī)構(gòu) > 游戲設(shè)計(jì)交流中心
科技時(shí)代到來,優(yōu)異也隨之而來,我們會(huì)去關(guān)注C語言程序設(shè)計(jì)猜數(shù)游戲,VB程序設(shè)計(jì)中怎么設(shè)計(jì)猜數(shù)游戲???!!!,如何編寫一個(gè)猜數(shù)游戲的編程,要求是猜對(duì)了,才可以退出游戲,設(shè)計(jì)一個(gè)猜數(shù)游戲,很復(fù)雜,要求語言C++??,還可以通過C語言程序設(shè)計(jì)猜數(shù)游戲,VB程序設(shè)計(jì)中怎么設(shè)計(jì)猜數(shù)游戲???!!!,如何編寫一個(gè)猜數(shù)游戲的編程,要求是猜對(duì)了,才可以退出游戲,設(shè)計(jì)一個(gè)猜數(shù)游戲,很復(fù)雜,要求語言C++??進(jìn)一步去來了解,接下來就跟隨作者一起去看看吧!
我把思路寫下來吧。首先你可以用random()生成個(gè)隨機(jī)數(shù)放到int i中。聲明計(jì)數(shù)n,n=0。然后輸入一個(gè)數(shù)input,用while循環(huán)來控制,條件是1.循環(huán)里面可以去判斷if(input>i) 提示:Your answer is HIGH,try again,scanf("%d",&input);n++;continue; if(input<i) 提示:Your answer is LOW,try again;scanf("%d",&input);n++;continue;if(input==i) if (n《=7)提示:。。。。else if(n>7&&n<15) 提示:。。。;else exit(0)}差不多給你寫完了,再不會(huì)就沒辦法了,我這里也沒有c運(yùn)行環(huán)境
天啊 你再加個(gè)判斷就可以啊 你是真的不會(huì)寫 還是懶得寫啊 把下面的代碼拷貝過去 自己運(yùn)行一下就知道怎么加這些限制 其實(shí)就加一個(gè)不可重復(fù)輸入數(shù)字和猜的字?jǐn)?shù)就可以了 把我的s和e 改成你的a和b就符合你的要求了 ---自己稍微改一點(diǎn)點(diǎn)Private Function getSerial(ByVal iLen As Integer, Optional ByVal bRepeat As Boolean = False) As StringIf iLen < 1 And iLen > 9 Then Exit IfDim iRnd As iCount As bExist As sSerial As iRnd = Int(Rnd(Now) * 9) If Not bRepeat Then For iCount = 1 To Len(sSerial) If iRnd = Val(Mid(sSerial, iCount, 1)) Then bExist = True Exit For Else bExist = False End If Next End If If Not bExist Then sSerial = iRnd & sSerial End IfLoop While Len(sSerial) < iLen'Debug. = Function (bEqual As Boolean, ByVal inString As String, ByVal cmpString As String) As StringDim iCount As jCount As iSame As iExist As iCount = 1 To Len(cmpString) For jCount = 1 To Len(inString) If Mid(cmpString, iCount, 1) = Mid(inString, jCount, 1) Then If jCount = iCount Then iSame = iSame + 1 Else iExist = iExist + 1 End If End If iSame = Len(cmpString) Then = "OK.." bEqual = TrueElse = iSame & "S" & iExist & "E " & inString bEqual = FalseEnd IfEnd Sub Command1_Click()'Debug.Print serial(8, True)Dim b As .Print (b, Text1.Text, Text2.Text)If b Then Command1.Enabled = False Text2.Visible = TrueEnd IfEnd Sub Command2_Click()Picture1.ClsText1.Text = ""Text2.Text = getSerial(5)Text2.Locked = TrueText2.Visible = .Enabled = TrueEnd Sub
import java.util.Scanner; import java.util.Random; public class Game { public static void main(String[] args) { int x,count1=1; do { int count; Random generator = new Random(); System.out.println("input is "); Scanner scan1 =new Scanner(System.in); int num =scan1.nextInt(); count =generator.nextInt(1001)+1; if (num==count) System.out.println("Right"); System.out.println("Times is "+count1); if (num-count>0 ) System.out.println("larger"); else System.out.println("smaller"); System.out.println("Go on ?"); do {System.out.println("please input Y(yes) or N(no)"); Scanner scan2=new Scanner(System.in); String message=scan2.nextLine(); String letter1="Y",letter2="N"; if (message.equals(letter1)) { x=2; ++count1; } else { if(message.equals(letter2)) {x=1; System.out.println("Game over!"); } else {System.out.println("please type rightly"); x=0;} } } while(x==0); } while(x-2==0); } } (java編)
給個(gè)Fibonacci數(shù)列,固定兩個(gè)數(shù)的,其他的你可以參考了:#include <stdio.h>#define N 8#define M 13int fib(int n){ int a = 0, b = 1, c; int i; if (0 == n) return 0; for (i = 0; i < n; i++) { c = b; b += a; a = c; } return b;}void main(){ int i = 0; while (1) { if (fib(i) == N && fib(i + 1) ==M) { printf("%d \n", fib(i + 2)); break; } i++; }}
上文講述了C語言程序設(shè)計(jì)猜數(shù)游戲,VB程序設(shè)計(jì)中怎么設(shè)計(jì)猜數(shù)游戲???!!!,如何編寫一個(gè)猜數(shù)游戲的編程,要求是猜對(duì)了,才可以退出游戲,設(shè)計(jì)一個(gè)猜數(shù)游戲,很復(fù)雜,要求語言C++??,大致對(duì)C語言程序設(shè)計(jì)猜數(shù)游戲,VB程序設(shè)計(jì)中怎么設(shè)計(jì)猜數(shù)游戲???!!!,如何編寫一個(gè)猜數(shù)游戲的編程,要求是猜對(duì)了,才可以退出游戲,設(shè)計(jì)一個(gè)猜數(shù)游戲,很復(fù)雜,要求語言C++??有個(gè)簡單了解,如還需深了解請(qǐng)聯(lián)系作者。
只要一個(gè)電話
我們免費(fèi)為您回電