本来挺简单的一个程序,但突然想把《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. PHPUnit_Framework_Assert单元测试

    先发下简书的干货: 教你一步一步写一个phpunit testcase:https://www.jianshu.com/p/ba6829a6f3ec 程序地址 https://github.com/y ...

  2. HDU-4031-Attack(树状数组)

    Problem Description Today is the 10th Annual of "September 11 attacks", the Al Qaeda is ab ...

  3. 【BZOJ2006】[NOI2010]超级钢琴 ST表+堆

    [BZOJ2006][NOI2010]超级钢琴 Description 小Z是一个小有名气的钢琴家,最近C博士送给了小Z一架超级钢琴,小Z希望能够用这架钢琴创作出世界上最美妙的音乐. 这架超级钢琴可以 ...

  4. CAFFE学习笔记(二)Caffe_Example之测试mnist

    这一次的博客将接着上一次的内容,简单讲解一下如何使用训练后的网络lenet_iter_5000.caffemodel与lenet_iter_10000.caffemodel. 1.在网络训练完毕后,将 ...

  5. iOS 蓝牙开发之(CoreBlueTooth)

    CoreBlueTooth 简介: 可用于第三方的蓝牙交互设备 设备必须支持蓝牙4.0 iPhone的设备必须是4S或者更新 iPad设备必须是iPad mini或者更新 iOS的系统必须是iOS 6 ...

  6. 关于js sort排序方法

    sort() 方法用于对数组的元素进行排序. 语法:arrayObject.sort(sortby):参数sortby可选.规定排序顺序.必须是函数. 当方法不带参数的时候,将按照字符编码顺序进行排序 ...

  7. Struts2学习总结(完整版)

    一.搭建struts2环境 1.jar包的导入 主要是到 解压其中的一个工程,得到里面lib下包含的jar包 把这里的所有的jar包拷贝到项目的 WEB-INF目录下的lib文件夹下面. 2.配置st ...

  8. Shell中的while循环

    while循环的格式   while expression do command command ``` done 1.计数器控制的while循环    主要用于已经准确知道要输入的数据和字符串的数目 ...

  9. 使用curl / wget命令上传下载FTP

    curl可以在shell下轻松上传下载ftp上的文件,相比ftp命令更具有优势,因为它能在单命令条件下,下载或者上传一个ftp文件,甚至可以删除文件. 下面看实例: 1.列出ftp服务器上的目录列表: ...

  10. 认识CoreData—使用进阶

    之前两篇文章都比较偏理论,文字表达比较多一些,但都是干货!学习时先理解理论知识,才能更好的帮助后面的理解.在这篇文章中,将会涉及关于CoreData的一些复杂操作,这些操作会涉及分页查询.模糊查询.批 ...