本来挺简单的一个程序,但突然想把《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. hihoCoder#1037 : 数字三角形(DP)

    [题目链接]:click here~~ 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 问题描写叙述 小Hi和小Ho在经历了螃蟹先生的任务之后被奖励了一次出国旅游的机会,于是他 ...

  2. Spring IOC(通过实例介绍,属性与构造方法注入)

    概括说明:下面通过实例介绍下属性方法注入.构造方法注入 1.源码结构图 2.代码介绍 (1).Dao接口 :UserDAO (2).Dao接口实现:UserDAOImpl (3).实体类:User ( ...

  3. 大数据学习系列(1)-- linux之文件系统结构介绍

    1./ 根目录 --------- 所有目录挂在其下 2./boot --------- 存放Ubuntu内核和系统启动文件.系统启动时这些文件先被装载. 3./etc --------- 系统的配置 ...

  4. centos6安装nginx最详细步骤

    第一步:在centos下面下载 nginx          wget http://nginx.org/download/nginx-1.2.9.tar.gz 解压 tar zxf nginx-1. ...

  5. 【深度学习】ubuntu16.04下安装opencv3.4.0

    1.首先安装一些编译工具 # 安装编译工具 sudo apt-get install build-essential # 安装依赖包 sudo apt-get install cmake git li ...

  6. C# 汉字编码GB2312转换

    功能界面 源码: using System; using System.Collections.Generic; using System.ComponentModel; using System.D ...

  7. 2018年长沙理工大学第十三届程序设计竞赛 C 取手机 【概率】

    链接:https://www.nowcoder.com/acm/contest/96/C 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536 ...

  8. iOS 读取本地Json文件

    之前写过类似的方法 今天写这个 的目的是 应对开发过程中面对 服务端数据刚定下模型 但是接口不通 的情况下 不耽误客户端开发进度 + (id)getJsonDataJsonname:(NSString ...

  9. c的详细学习(7)指针学习(一)

    指针是c语言的一个重要概念,指针类型是c语言最有特色的数据类型: *利用指针编写的程序可使调用函数共享变量或数据结构,实现双向数据通信: *可以实现内存空间的动态存储分配:可以提高程序的编译效率和执行 ...

  10. [原创]java WEB学习笔记06:ServletContext接口

    本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...