本来挺简单的一个程序,但突然想把《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. Android中经常使用的工具类02

    1.读取手机联系人信息 一般用在读取手机通讯录上传,这一块比較多. import java.util.ArrayList; import java.util.List; import android. ...

  2. 批处理--md5校检

    @echo off rem 获取文件xx.zip的MD5 for /f "delims=" %%i in ('md5.exe xx.zip') do (set md5_var=%% ...

  3. 【BZOJ3563/3569】DZY Loves Chinese II 线性基神题

    [BZOJ3563/3569]DZY Loves Chinese II Description 神校XJ之学霸兮,Dzy皇考曰JC. 摄提贞于孟陬兮,惟庚寅Dzy以降. 纷Dzy既有此内美兮,又重之以 ...

  4. element-ui table 点击分页table滚动到顶部

    在做项目中,碰到一个问题,table加了固定头,内容可滚动,当滚到table底边时,点击分页后还在底边 解决方法:设置table的 ref='multipleTable' //切换分页的方法加上下面这 ...

  5. URAL 1181 Cutting a Painted Polygon【递归+分治】

    题目: http://acm.timus.ru/problem.aspx?space=1&num=1181 http://acm.hust.edu.cn/vjudge/contest/view ...

  6. recognition rate generalization识别率 泛化

    http://www1.inf.tu-dresden.de/~ds24/lehre/ml_ws_2013/ml_11_hinge.pdf Two extremes: • Big

  7. 【译】前端开发者都应知道的 jQuery 小技巧

    回到顶部按钮 通过使用 jQuery 中的 animate 和 scrollTop 方法,你无需插件便可创建一个简单地回到顶部动画: // Back to top $('a.top').click(f ...

  8. zip 解压脚本

    zip 解压脚本 gpk-unzip.py #!/usr/bin/env python # -*- coding: utf-8 -*- # unzip-gbk.py import os import ...

  9. android ui篇 自己写界面

    对于一些较为简单的界面则自己进行写. 在这里就需要了解xml文件中一些基本的属性以及android手机的知识. 一.目前手机屏幕像素密度基本有5种情况.(以下像素密度简称密度) 密度 ldpi mdp ...

  10. 销售订单、外向交货单、交货 bapi

    转自[http://www.cnblogs.com/elegantok/archive/2009/10/18/1585398.html]***********SALES ORDER INPUT CRE ...