試作C語言俄羅斯輪盤小遊戲

2021-08-29 16:36:23 字數 1600 閱讀 7677

學習資料結構時的習作。

#include

#include

#include

#define random(x) (rand()%x)

typedef

struct node

;//構建雙迴圈鍊錶

struct node*

init

(int sum)

p->next=h;

h->prev=p;

return h->next;

}//構建鍊錶初始化函式

intmain()

starter:

printf

("choose your number in %d players:\r\n"

,iplayers)

;scanf

("%d"

,&istart);if

(istart<

1||istart>iplayers)

//輸入資訊

printf

("you are the player %d out of %d.good luck.\r\n"

,istart,iplayers)

;struct node* gun=

init(6

);//槍原型鍊錶構建

struct node* players=

init

(iplayers)

;//player原型鍊錶構建

sleep(1

);printf

("deciding the first player...");

struct node* plr=players;

for(

int i=

1;i<=

random

(iplayers*2-

1)+1

;i++

)sleep(1

);printf

("%d.\r\n"

,plr->elem)

;sleep(1

);//決定從幾號開始

int istate=0;

int irounds=-1

;while(1

) s->elem=1;

//重裝子彈

for(

int i=

1;i<=

random(59

)+1;i++

)//隨機轉輪

sleep(1

);printf

("done.\r\n");

sleep(1

);while(1

)else

if(s->elem)

//判斷槍內是否有子彈

break

;//跳出

}else

} irounds++

;//累計淘汰player

if(plr->next==plr||istate==-1

)//玩家掛掉或者只剩玩家時結束,跳出}if

(istate==-1

)//判斷勝負

else

return0;

}

C語言小遊戲之俄羅斯方塊

include include include sleep 函式的標頭檔案 include include define mod 28 define size n 19 控制邊框的高度 define size m 12 控制邊框的寬度 int a 100 定義排行榜 int cur x,cur y,...

小遊戲 俄羅斯方塊(C 版)

大一作品,留念 include include include kbhit include rand,srand include define wide 15 define hight 18 define period 500 typedef struct point point 1 1 4 4 1...

資料結構實踐專案之俄羅斯輪盤賭小遊戲

俄羅斯輪盤賭,想必很多人都聽說過,一種殘忍的賭博遊戲。遊戲的道具是一把左 其規則也很簡單 在左 中的 6 個彈槽中隨意放入一顆或者多顆子彈,在任意旋轉轉輪之後,關上轉輪。遊戲的參加者輪流把手槍對著自己,扣動扳機 中槍或是怯場,即為輸的一方 堅持到最後的即為勝者。本節實踐專案同輪盤賭類似,遊戲規則 n...