急需一个C语言 猜拳游戏的源代码!!!!

急需一个C语言 猜拳游戏的源代码!!!!,第1张

分类: 电脑/网络 >>程序设计 >>其他编程语言

问题描述:

急需一个C语言 猜拳游戏的源代码!!!!急需一个轿枯如C语言 猜拳游戏的源代码!!!!急需一个C语言 猜拳游戏的源代码!!!!急需一个C语言 猜拳游戏的源代码!!!!急需一个C语败败言 猜拳游戏的源代码!!!!急需一个C语言 猜拳游戏的源代码!!!!急需一个C语言 猜拳游戏的源代码!!!!

解析:

enum p_r_s{

paper,rock,scissors,game,help,instructions,quit

}

#include <stdio.h>

main()

{

enum p_r_s player,machine

enum p_r_s selection_by_player(),selection_by_machine()

int win,lose,tie

win=lose=tie=0

instructions_for_the_player()

while((player=selection_by_player())!=quit)

switch(player){

case paper:

case rock:

case scissors:

machine=selection_by_machine()

if(player==machine){

++tie

printf("\n a tie")

}

else if(you_won(player,machine)){

++win

printf("\n you won")

}

else{

++lose

printf("\n i won")

}

break

case game:

game_status(win,lose,tie)

break

case instructions:

instructions_for_the_player()

break

case help:

help_for_the_player()

break

}

game_status(win,lose,tie)

printf("\n\nBYE\n\n")

}

instructions_for_the_player()

{

printf("\n%s\n\n%s\n\n%s\n%s\n%s\n\n%s\n%s\n%s\n\n%s\n%s\n%s",

"PAPER,ROCK,SCISSORS",

"In this game",

"p is for paper,",

"r is for rock,",

"s is for scissors.",

"Both the player and the machine will choose one",

"of p,r,or s. If the o choices are the same,",

"then the game is a tie. Otherwise:",

"\"paper covers the rock\" (a win for paper),",

"\"rock breaks the scissors\" (a win for rock),",

"\"scissors cut the paper\" (a win for scissors).")

printf("\n\n%s\n\n%s\闭启n%s\n%s\n%s\n\n%s\n\n%s",

"There are other allowable inputs:",

"g for game status (the number of wins so far),",

"h for help,",

"i for instructions (reprin these instructions),",

"q for quit (to quit the game).",

"This game is played repeatedly until q is entered.",

"Good luck!")

}

enum p_r_s selection_by_player()

{

char c

enum p_r_s player

printf("\n\ninput p,r,or s:")

while((c=getchar())==''||c=='\n'||c=='t')

switch(c){

case 'p':

player=paper

break

case 'r':

player=rock

break

case 's':

player=scissors

break

case 'g':

player=game

break

case 'i':

player=instructions

break

case 'q':

player=quit

break

default:

player=help

}

return(player)

}

enum p_r_s selection_by_machine()

{

static int i

i=++i%3

return((i==0)? paper:((i==1)? rock:scissors))

}

you_won(player,machine)

enum p_r_s player,machine

{

int victory

if(player==paper)

victory=machine==rock

else if(player==rock)

victory=machine==scissors

else/*player==scissors*/

victory=machine==paper

return(victory)

}

game_status(win,lose,tie)

{

printf("\nGAME STATUS")

printf("\n\n%7d%s\n%7d%s\n%7d%s\n%7d%s",

win,"games won by you",

lose,"games won by me",

tie,"game tied",

win+lose+tie,"games played:")

}

help_for_the_player()

{

printf("\n%s\n\n%s\n%s\n%s\n%s\n%s\n%s\n%s",

"the following characters can be used for input:",

" p for paper",

" r for rock",

" s for scissors",

" g to find out the game status",

" h to print this list",

" i to reprint the instructions for this game",

" q to quit this game")

}

本原代码是基于C语言的原程序。是经典中的小游戏。-primitive code is based on the C language of the original procedure. Classic is a small game.

一个小游戏,用C语言编写的:俄罗斯方块.C原码及应用程序都在里面哦 -a small game using the C language : Russian cubes. The original C code and application procedures inside oh

十全十美游戏原程序,c语言-perfect game program, language c

上数据结构时,自己用C语言做的小游戏穗派,做得不好,请大家原谅。-structure on the data they used C language to the small games, done well, please forgive me.

大家都耍过文曲星中的猜数字的游戏吧 !! 最近我在学习C语言。写了个菜鸟的C语言的猜数字的游戏程序的原代码-rings off the viewing of the game! ! I recently learning C language. Wrote a birdie C language viewing of the games original code procedures

  这是我在大学二年级学习C语言课程时,作为“练笔”而编写的一个小程序(当时在我眼里可却是一个大程序!)其主要特点有:1、正真做到了全中文界面(不需要UCDOS *** 作系支持) 2、大量的图形猜模贺特技(如图像的显隐技术、图像穿插技术、多任务仿真技术等) 3、纯C语言打造(不含任何C++知识) 4、实现了街机“俄罗斯方块”绝大部分功能(如动画、声音、速度变化) 5、用户可根据自据的习惯自由地调整“游戏 *** 作键” 6、方法独特,全部语句和技术都是我本人原创,没有参考过任何相关代码 7、防“跟踪调试”技术,防“版权篡改”技术 8、……-

  这个程序是模仿Windows中的扫雷小游戏制作的,该程序只是实现了扫雷游戏的主体部分,诸如计分、升级部分都没有做。这个程序可以作为初学者学习C语言绘图和游戏的实例。 该程序在Turbo C2.0 下编译通过 由于扫雷游戏是用鼠标 *** 作的,而Turbo C中提供的鼠标驱动程序在Windows xp下不可用,所以我随源程序提供了一个鼠标驱动的头文件,须将将该头文件复制到Turbo C2.0 的安装目录下的“include”文件夹中方可编译或运行码备,也可自行修改原文件使之包含该投文件。 注:该鼠标驱动程序是我在网上找到的,其出处我已无法考证,如果侵犯了作者的权利还请作者与我联系。 由于在我的电脑上Turbo C图形环境下显示数字会有问题(估计是系统问题),所以程序中雷周围的数字1-8我用a-h代替,看不顺眼的可以自己修改原程序。-

c语言 猜拳游戏的原代码就是这个 已经测试成功了呀-language of the original game is the code has been tested successfully ah

俄罗斯方块对战版c语言原代码。希望大家能喜欢。是比较简单的一个代码,游戏开发高手请指教。-Tetris screen version of the original C language code. Hope you will like. It is a relatively simple code, game development experts please advise.

用linuX 下的C语言 运用CURSES编写的俄罗斯方块游戏,很好,这个是本人原创,值得参考-linuX use the C language CURSES prepared by the Russian box game, well, this is the original, worthy of reference

package Demo

import java.util.Random

import java.util.Scanner

public class Demo12 {

public static void main(String[] args) 樱衡山{

String[] str = { "石头", "剪刀", "布" }

Random ram = new Random()

int y, n, i

while (true) {

System.out.println("菜单:\n1、开始猜拳  \n9、退出")

Scanner scan = new Scanner(System.in)

System.out.print("请选择:")

String s = scan.nextLine()

if ("1".equals(s.trim())) {

y = 0

n = 0

i = 0

while (true) {

try {

System.out.println("请出拳:1、石头拦银  2、剪刀  3、布")

int s1 = Integer.parseInt(scan.nextLine())

if (s1 > 0 && s1 < 4) {

System.out.println("你  出:" + str[s1 - 1])

int s2 = ram.nextInt(3)

System.out.println("我  出:" + str[s2])

if (s1 == (s2 + 1)) {

System.out.println("这次是平局")

} else if ((s1 == 1 && s2 == 1)

|| (s1 == 2 && s2 == 2)

|| (s1 == 3 && s2 == 0)) {

System.out.println("这次你赢了!")

y++

} else if ((s1 == 1 && s2 == 2)

|| (s1 == 2 && s2 == 0)

|| (s1 == 3 && s2 == 1)) {

System.out.println("这次你输了!")

n++

}

if (i == 2) {

if (y > n) {

System.out.println("你赢了  " + y + ":" + n)

} else if (y < n) {

System.out.println("你输了  " + y + ":" + n)

} else {

System.out.println("平局  " + y + ":" + n)

}

break

}

i++

} else {

System.out.println("输入有误!")

}

} catch (Exception ex) {

System.out.println("输入有误!")

}

}

} else if ("9".equals(s.trim())) {

System.out.println("退出成功")

return

} else {

System.out.println("指令错误~")

}

}

}

}

菜单:

1、开始猜拳

9、退出

请选择:2

指令错误~

菜单:

1、开始猜拳

9、退出

请选择:1

请出拳:1、石头  2、剪刀  3、布

2

你  出:剪刀

我  出:布

这次你赢了!

请出拳:1、石头  2、剪刀  3、布

4

输入有误!

请出拳:1、石头  2、剪刀  3、布

3

你  出:布

我  出:布

这次是平局

请出拳:1、石头  2、剪刀  3、布

1

你  出:石头

我  出:石头

这次是平局

你脊中赢了  1:0

菜单:

1、开始猜拳

9、退出

请选择:9

退出成功


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8229510.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-14
下一篇2023-04-14

发表评论

登录后才能评论

评论列表(0条)

    保存