本来挺简单的一个程序,但突然想把《Friends》给糅合进去,就多花了一些心思,这是我写过最有趣的程序了。

#include <stdio.h>
#include <stdlib.h>
#include <time.h> 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 <Friends>.\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。

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

C语言小程序(七)、石头剪刀布的更多相关文章

  1. C语言小程序——推箱子(窄字符和宽字符)

    C语言小程序——推箱子(窄字符Version) 推箱子.c #include <stdio.h> #include <conio.h> #include <stdlib. ...

  2. 通过反汇编C语言小程序学习Liunx汇编语言

    大家好!    我是来自山东师范大学的吴乐.    今天在<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 ...

  3. Linux下简单C语言小程序的反汇编分析

    韩洋原创作品转载请注明出处<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 写在开始,本文为因为参加MOO ...

  4. c语言小程序以及java生成注释文档方法

    c语言小程序:sizeof和strlen() sizeof运算符以字节为单位给出数据的大小,strlen()函数以字符为单位给出字符串的长度,字符和字节不是一回事. char类型用于存储字母和标点符号 ...

  5. Linux C语言小程序

    Linux C语言小程序 #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include & ...

  6. 微信小程序(七)-项目实例(原生框架 MINA转云开发)==02-云开发-配置

    云开发:1.就是用云函数的型式来使用云存储和云数据库完成各种操作!     2.只关注调什么函数,完成什么功能即可,无需关心HTTP请求哪一套!     3.此模式不代表没有服务器,只是部署在云环境中 ...

  7. 自动生成.py文件头部的C语言小程序

    每次都 vi xxx.py 然后再打 #!/usr/bin/env python 等等的程序头信息感觉有点麻烦,于是便想着写一个小程序自动生成这些头信息了,顺便在 ~/.bashrc 里写入 alia ...

  8. c语言小程序

    这是一个用c语言写的小程序,功能是随机输出30道100以内的四则运算,先生成两个随机数,再通过随机数确定四则运算符号,最后输出题目. #include<iostream> using na ...

  9. C语言小程序之整除

    看到有人要求用C语言写这样一个小程序,就拿来温习一下 需求:输出从1到2015这2015个自然数中,能被4或5整除,但不能被30整除的数,并计算有多少个数.   #include<stdio.h ...

随机推荐

  1. MongoDB可视化工具 Studio 3T

    告别终端使用可视化工具Studio 3T对MongoDB进行数据库的操作. 简单的使用步骤介绍 1.启动MongoDB服务器(方法见MongoDB介绍与安装中的介绍) 2.连接MongoDB服务器  ...

  2. Swift开发教程--怎样设置状态栏的文字颜色

    第一步:在Info.plist中设置UIViewControllerBasedStatusBarAppearance 为NO 第二步:在viewDidLoad中加一句 UIApplication.sh ...

  3. -[ASIDataCompressor compressBytes:length:error:shouldFinish:] in ASIDataCompressor.o

    本文转载至 http://blog.csdn.net/m372897500/article/details/38293973 -[ASIDataCompressor compressBytes:len ...

  4. 【BZOJ2422】Times 树状数组

    [BZOJ2422]Times Description 小y作为一名资深的dotaer,对视野的控制有着深刻的研究.每个单位在一段特定的时间内会出现在小y的视野内,除此之外的时间都在小y看不到的地方. ...

  5. OpenCV玩耍(一)批量resize一个文件夹里的所有图像

    鉴于用caffe做实验的时候,里面牵扯到一个问题是必须将训练集和测试集都转成256*256的图像,而官网给出的代码又不会用,所以我用opencv转了.其实opencv只转一幅图会很简单,关键在于“批量 ...

  6. 开始翻译《Beginning SharePoint 2013 Development》

    伙同涂曙光@kaneboy 和柴晓伟@WindieChai 翻译Beginning SharePoint 2013 Development 作者是Steve Fox,传说中的Andrew Connel ...

  7. Ubuntu中安装FTP 服务器自己踩得坑

    12点多了,擦!做个码农真不容易呀! 系统:Ubuntu16.04 安装:FTP 步骤: 1.不管有没有一上来我先卸载: sudo apt-get purge vsftpd 2.再安装:sudo ap ...

  8. 我的Android进阶之旅------>Android KeyCode列表

    KEYCODE列表 电话键 KEYCODE_CALL 拨号键 5 KEYCODE_ENDCALL 挂机键 6 KEYCODE_HOME 按键Home 3 KEYCODE_MENU 菜单键 82 KEY ...

  9. Java之线程池(二)

    关于线程和线程池的学习,我们可以从以下几个方面入手: 第一,什么是线程,线程和进程的区别是什么 第二,线程中的基本概念,线程的生命周期 第三,单线程和多线程 第四,线程池的原理解析 第五,常见的几种线 ...

  10. CVPR 2018paper: DeepDefense: Training Deep Neural Networks with Improved Robustness第一讲

    前言:好久不见了,最近一直瞎忙活,博客好久都没有更新了,表示道歉.希望大家在新的一年中工作顺利,学业进步,共勉! 今天我们介绍深度神经网络的缺点:无论模型有多深,无论是卷积还是RNN,都有的问题:以图 ...