日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

c语言 石头剪刀布的小程序,C语言小程序(七)、石头剪刀布

發布時間:2023/11/27 生活经验 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言 石头剪刀布的小程序,C语言小程序(七)、石头剪刀布 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

本來挺簡單的一個程序,但突然想把《Friends》給糅合進去,就多花了一些心思,這是我寫過最有趣的程序了。

#include

#include

#include

int getrand()

{

srand(time(NULL));

return rand()%3;

}

int win_lose(int choice)

{

int rand = 0;

char *p[3] = {"SCISSORS", "STONE", "CLOTH"};

rand = getrand();

printf("

The system give the %s.

",p[rand]);

rand++;

if(choice == rand)//even

{

printf("

Joey:Hei, How you doing? We call it even, all right?

");

printf("And if you are Chandler M. Bing, of course you will say ok.

");

return 0;

}

else if(rand==choice-1 || rand==choice+2)//win

{

printf("

Monica:Of course the winner is Me. I knew it, you such a loser,

");

printf("you can't win me ever!

");

printf("Ross:It can't be, I am Profess Geller and I am a doctor.

");

printf("I can't lose, you must cheat me last time.

");

return 1;

}

else//lose

{

printf("

Rachel:Oh my god! Oh my god! I can't believe this. Phoebe,

");

printf("you are my best friend, can we forget this?

");

printf("Phoebe:Ok, But it is when you say that you don't love Ross any more.

");

return -1;

}

}

int main()

{

int choice = 0;

int flag = 0;

int rot = 0;

char ch;

system("clear");

printf("***********************************************");

printf("

Lets play a game about .

");

printf("***********************************************");

printf("

Janice:You don't want to see me any more, right?

So just chose a number quickly:

");

printf("

1.SCISSORS

2.STONE

3.CLOTH

");

do

{

printf("

Input your choice:");

scanf("%d",&choice);

if(choice>0 && choice<4)

{

flag = win_lose(choice);

while((ch=getchar())!='

' && ch!=EOF);

printf("

Gunther:I want to see Rachel");

if(flag == -1)

printf(" again");

printf(", so please replay it.(y/n)");

}

else

{

while((ch=getchar())!='

' && ch!=EOF);

printf("

Monica:What's the matter with you! What you need is just chose

");

printf("a number from 1 to 3. So are you ready?(y/n)");

}

ch = getchar();

}

while(ch=='y' || ch=='Y' || ch=='

');

printf("

Goodbye!

");

return 0;

}

謹以此程序紀念下《Friends》,Monica、Ross、Joey、Rachel、Chandler、Phoebe。

還請諸位大俠自動忽略那蹩腳的英語。

總結

以上是生活随笔為你收集整理的c语言 石头剪刀布的小程序,C语言小程序(七)、石头剪刀布的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。