博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C语言小程序(七)、石头剪刀布
阅读量:4978 次
发布时间:2019-06-12

本文共 2223 字,大约阅读时间需要 7 分钟。

本来挺简单的一个程序,但突然想把《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("\nThe system give the %s.\n",p[rand]); rand++; if(choice == rand) //even { printf("\nJoey:\tHei, How you doing? We call it even, all right?\n"); printf("\tAnd if you are Chandler M. Bing, of course you will say ok.\n"); return 0; } else if(rand==choice-1 || rand==choice+2) //win { printf("\nMonica:\tOf course the winner is Me. I knew it, you such a loser,\n"); printf("\tyou can't win me ever!\n"); printf("Ross:\tIt can't be, I am Profess Geller and I am a doctor.\n"); printf("\tI can't lose, you must cheat me last time. \n"); return 1; } else //lose { printf("\nRachel:\tOh my god! Oh my god! I can't believe this. Phoebe,\n"); printf("\tyou are my best friend, can we forget this?\n"); printf("Phoebe:\tOk, But it is when you say that you don't love Ross any more.\n"); return -1; }}int main(){ int choice = 0; int flag = 0; int rot = 0; char ch; system("clear"); printf("***********************************************"); printf("\n\tLets play a game about
.\n"); printf("***********************************************"); printf("\nJanice:\tYou don't want to see me any more, right? \n\tSo just chose a number quickly:\n"); printf("\n1.SCISSORS\n2.STONE\n3.CLOTH\n"); do { printf("\nInput your choice:"); scanf("%d",&choice); if(choice>0 && choice<4) { flag = win_lose(choice); while((ch=getchar())!='\n' && ch!=EOF); printf("\nGunther:I want to see Rachel"); if(flag == -1) printf(" again"); printf(", so please replay it.(y/n)"); } else { while((ch=getchar())!='\n' && ch!=EOF); printf("\nMonica:\tWhat's the matter with you! What you need is just chose\n"); printf("\ta number from 1 to 3. So are you ready?(y/n)"); } ch = getchar(); } while(ch=='y' || ch=='Y' || ch=='\n'); printf("\nGoodbye!\n"); return 0;}
谨以此程序纪念下《Friends》,Monica、Ross、Joey、Rachel、Chandler、Phoebe。

还请诸位大侠自动忽略那蹩脚的英语。

转载于:https://www.cnblogs.com/java20130726/p/3218664.html

你可能感兴趣的文章
上周热点回顾(8.18-8.24)
查看>>
Feature toggle
查看>>
day02
查看>>
gvim 配置Pydiction
查看>>
Linux安装指定mysql版本
查看>>
分布式锁的三种实现方式
查看>>
poj 2109 pow函数也能这么用?p的开n次方
查看>>
Oracle database link
查看>>
python调用shell小技巧
查看>>
TL431的几种常用用法
查看>>
js 经典闭包题目详解
查看>>
在项目中移除CocoaPods
查看>>
【洛谷】CYJian的水题大赛【第二弹】解题报告
查看>>
POJ 1703 Find them, Catch them【种类/带权并查集+判断两元素是否在同一集合/不同集合/无法确定+类似食物链】...
查看>>
L1-5. A除以B【一种输出格式错了,务必看清楚输入输出】
查看>>
Git一分钟系列--快速安装git客户端
查看>>
纵越6省1市-重新启动
查看>>
hive安装以及hive on spark
查看>>
jz1074 【基础】寻找2的幂
查看>>
Wannafly模拟赛5 A 思维 D 暴力
查看>>