史萊姆論壇

返回   史萊姆論壇 > 專業主討論區 > 程式語言討論區
忘記密碼?
論壇說明

歡迎您來到『史萊姆論壇』 ^___^

您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的!

請點擊這裡:『註冊成為我們的一份子!』

Google 提供的廣告


發文 回覆
 
主題工具 顯示模式
舊 2008-01-04, 05:50 PM   #1
rang0419
註冊會員
榮譽勳章

勳章總數
UID - 285008
在線等級: 級別:0 | 在線時長:4小時 | 升級還需:1小時
註冊日期: 2007-11-07
文章: 24
精華: 0
現金: 35 金幣
資產: 35 金幣
預設 疑問 - 如何使用C寫一個猜英文單字的遊戲?

以前常玩的猜字母遊戲@@

老師會話一個人上吊的圖~~~

然後26個字母 去猜一個單子~~~


不過要寫程一個遊戲 我覺得好難阿


誰可以幫幫我


1.The computer randomly selects an English word from a list of at least 10 English words.

2.The computer randomly exposes some characters of an English word of the lenght n. At least 1 character is exposed and at maximum n - 1 character.

3.The player guesses character by character until the word is solved or the 8 times of wrong guesses is exceeded.

4.Each time a correct character is guessed the character is exposed.

5.They player can decide to continue to play or not.

Hint:

1.To get the string length, use the strlen function.

2.To compare two strings, use the strcmp function.

3.To count the number of strings, refer to the following code:



main() {



char *words[] = {"computer", "information", "engineering", "programming"};

char guess[30];

int i, n = sizeof(words)/sizeof(char *);



printf("List of string: ");

for (i = 0; i < n; i++) printf("%s ", words[i]);



i = rand() % n;

printf("\nEnter your guess : ");

scanf("%s", guess);

printf("Your guess is \"%s\".\n", guess);

printf("Computer selects \"%s\".\n", words[i]);

if (strcmp(guess, words[i])) printf("Your guess is wrong.\n");

else printf("Your guess is correct.\n");

}

A possible session could look like as follows:



The word to guess: -a--c

Your guess => o

The word to guess: -a--c

Your guess => m

The word to guess: ma--c

Your guess => l

The word to guess: ma--c

Your guess => g

The word to guess: mag-c

Your guess => i

Correct! The word is magic.

====================================================

Continue (Y/N)? Y

The word to guess: wo--e-

...

...

You guessed wrong more than 8 times. The word is wonder.

====================================================

Continue (Y/N)? N

Bye!






拜託一下了
rang0419 目前離線  
送花文章: 5, 收花文章: 0 篇, 收花: 0 次
回覆時引用此帖
發文 回覆



發表規則
不可以發文
不可以回覆主題
不可以上傳附加檔案
不可以編輯您的文章

論壇啟用 BB 語法
論壇啟用 表情符號
論壇啟用 [IMG] 語法
論壇禁用 HTML 語法
Trackbacks are 禁用
Pingbacks are 禁用
Refbacks are 禁用

相似的主題
主題 主題作者 討論區 回覆 最後發表
英文板的 XP如何使用中文軟體(繁體) kohoku 軟體應用問題討論區 2 2003-05-11 01:37 PM
Ghost 這一個程式該如何使用 電腦狂 軟體應用問題討論區 2 2003-02-07 06:26 AM
請問如何使用Alcohol 120% 製作虛擬光碟來玩遊戲? I am Jerry 一般電腦疑難討論區 4 2003-02-02 11:31 PM
請問如何使用DiscJuggler備份PS遊戲片 sis6326 軟體應用問題討論區 0 2002-12-21 06:54 PM


所有時間均為台北時間。現在的時間是 02:41 AM


Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2024, Jelsoft Enterprises Ltd.


SEO by vBSEO 3.6.1