c++-请帮看一下一道C++的题目。还可另得100C(总计200C)

问题描述

请帮看一下一道C++的题目。还可另得100C(总计200C)

问题如下:

我们要创造一个游戏,这游戏是为了测量玩家在规定时间内能记得多少信息,以下是解析这游戏是如何玩的:
第一步:有两位玩家;
第二步:每个玩家开始都有十分;
第三步:游戏需要提示第一位玩家输入一段话。第二位玩家不允许看。

第四步:程序向第二位玩家展示第一位玩家输入的一段话,然后通过不断换行清除屏幕中的一段话。询问玩家是否准备好答题,如果还不行,就继续展示在屏幕上,这一次留在屏幕的时间会延长。每一次玩家需要再看一遍,玩家的分数就会从自己的总分里扣除。当分数变为零之后,这时候就交换角色。

第五步:一旦玩家准备好开始答题,第二位玩家则凭记忆输入那段话
第六步:你的程序得算出在玩家输入的问题和原始问题的字数,并且每个字母都得一样,这样玩家就会得到一分,但是不能超过原始的总分10分。

第七步:接着就交换角色

第八步:这个步骤一直持续到谁没有分数为止(那他就输掉)

要求程序需要用cstring中的strlen来确定问题的长度
需要用数组,数组下标。

小孩的解答如下,请斧正:
Algorithm for the programming assignment #2
Algorithm for the game of absorb material
Step1: Welcome the user and explain the purpose of how to use this program to play
Step1a: Display a heading (“absorbing material game”)
Step2: Get the name of players
---(step2a)Prompt the user

“Please input the name of the first player”

---Enter the name of first player (player[0])

---Read it in the data and store in a char variable

---Echo the name of the first player (display it)

“The first player’s name” amount the variable

---Ask the user if the name was correct (Y/N)

---If not, re-prompt and read until the user player is happy (repeat step 2a)

---(step 2b)Prompt the user again

“Please input the name of the second player”

---Enter the name of second player (player[1])

---Read it in the data and store in a char variable

---Echo the name of the second player (display it)

“The second player’s name”amount the variable

---Ask the user if the name was correct(Y/N)

---If not, re-prompt and read until the user player is happy (repeat step 2b)
Step3: Distribute the points
---(step 3a)Prompt the first user

“Please input the points of the game! (10 points)”

---Enter the number of the points ( int a)

---Read it in the data and store it in a int variable

---Echo the number of the points (display it)

“The number of the points at the before beginning the game”amount the variable

---Ask the user if the points meet with the requirement of the game(Y/N)

---If not, re-prompt and read until meet with the requirement (repeat step 3a)

---(step 3b)Prompt the second user

“Please input the points of the game! (10 points)”

---Enter the number of the points (int b)

---Read it in the data and store it in a int variable

---Echo the number of the points (display it)

“The number of the points at the before beginning the game”amount the variable

---Ask the user if the points meet with the requirement of the game(Y/N)

---If not, re-prompt and read until meet with the requirement (repeat step 3b)
Step4: Enter the question
---(step 4a)Prompt the first player

“Please input the question on the screen”

---Enter the question (char question[])

---Count the number of words of the question and store it in a int variable (int c)

---Read it in the data and store it in a char variable

---Echo the question (display it)

“The question is” among the variable

---Ask the first player if the question is correct(Y/N)

---If not, re-prompt and read until the user is happy (repeat step 4a)
Step5: Clear the question
---Prompt the second player

“Don’t see the problem when the first player enter the question”

---Display the question and disappear quickly( type the enter key)
Step6: Show the question for the second player
---Prompt the second player

“Are you ready to see the question and you have only three seconds to see (Y/N)”

---Enter the answer (char ch1)

---If the answer is Y (y)

---Read it in the data and store it in a char variable

---Echo the answer (display it)

“Your answer is”among the variable

---If yes, then do the next step

---Echo the time left (display it)

“Time-left:”among the positive number

Step7: Memory the question
---Prompt the second player

“You have five seconds to recall the question”

---Echo the time left (display it)

“Time-left:”among the positive number

Step8: Try to relax
---Prompt the second player

“Relax yourself before answering the question”

Step9: Is ready for the second player
---(step 9a)Prompt the second player

“Are you ready to answer the question? (Y/N)”

---Enter the answer (char ch2)

---Read it in the data and store it in a char variable

---Echo the answer (display it)
“Your answer is”among the variable

---Ask the second player if the answer is correct(Y/N)

---If not, re-prompt and read until the meet with the second player’s requirement

(repeat step 9a)

---If the second player answer is no

---Read it in the data and store it in a char variable

---(step 9b)Prompt the second player

“This time you have 30 seconds to see this question and remember it, but your

 Points will deducted” (points=points-1)

---Read the points in the data and store it in a integer variable

---Show the question on the screen

---Echo the time left (display it)

“Time-left:”among the positive number

---Prompt the second player

“You have ten seconds to recall the answer”

---Echo the time left (display it)

“Time-left:” among the positive number

---Prompt the second player

“Relax yourself before typing the question”

Step10: Begin to type the question
---Prompt the second player

“Begin to type the question”

---Enter the question (char question1[])

---Count the number of words of the question1 and store it in a int variable (int d)

---Read it in the data and store it in a char variable
Step11: Compare the number of words
---(step 11a)If the number of words in the same and the word(Y/N)

---If yes, then do the next step

---Echo a sentence (display it)

“You do a great job! And you can add one point to your points” (points=points+1)”

---Read it in the data and store it

---If no, then do the next step

---Echo a sentence (display it)

“Your point need to deducted by one point” (points=points-1)

---Read it in the data and store it
Step12: Switch turns
---Prompt the player

“The position of the player changes”

---Repeat the step from step 4 to step12 until one player has no point
Step13: Game over
---Prompt the player

“Who don’t have points?”

---If the first player don’t have points

---Echo a sentence (display it)

“The second player win the game”

---If the second player don’t have points

---Echo a sentence (display it)

“The first player win the game”

Step14: Re-play the game
---Prompt the player

“Do you want to play again? (Y/N)”

---If yes, then repeat the step from step2 to step13

---If no, then exit the game
Step15: Thank you for using this program to play

解决方案

是要控制台程序还是windows窗口程序?如果是两个玩家那需要两个客户端吧,中间用网络通讯?

解决方案二:

http://www.cnblogs.com/lzmfywz/archive/2012/03/15/2399403.html

解决方案三:

http://download.csdn.net/detail/a1193561652/9424503

做好了,不知道你还要不要,界面大致是这样的,是VS2010的工程。

解决方案四:

另得100C链接http://ask.csdn.net/questions/235147。
属于同一个问题。我将一同给分。还请大神不吝赐教

解决方案五:

看样子已经处理了 ? 我也就是来看看到底什么问题,好像很麻烦的样子

解决方案六:

建议用控制台显示输出来做

时间: 2024-11-03 03:42:33

c++-请帮看一下一道C++的题目。还可另得100C(总计200C)的相关文章

高手请帮看下-----------------我这个Gridview里的下拉菜单,为什么不能直接改?

问题描述 是这样,本来Gridview是直接显示一个后台绑定数据源的表格,但现在老大要求把"状态"列改成改成可以直接改的.而是我能让Gridview的那个状态列显示下拉框,选择不同的状态了,可是我变了状态,并没有保存到.后台是用RowCommand接收...应该怎么改呢,各位帮帮忙...很急....谢谢..//前台<asp:GridViewID="GridView1"OnRowCommand="GridView1_RowCommand"On

请帮看下这段发送Email的代码那里有问题

问题描述 publicboolSendEmail(stringfrom,stringto,stringsubject,stringbody){try{System.Net.Mail.MailMessagemsg=newSystem.Net.Mail.MailMessage();msg.From=newSystem.Net.Mail.MailAddress(from);msg.To.Add(to);msg.Subject=subject;msg.Body=body;msg.BodyEncoding

c++的问题-C++中的从文件中读取数据并用链表创建的问题,请帮我看一下我的代码在哪里出现了问题

问题描述 C++中的从文件中读取数据并用链表创建的问题,请帮我看一下我的代码在哪里出现了问题 Phone* creat() { ifstream file("Phone.txt"); if( !file ) { for( int i = 0 ; i < 7; i++ ) cout< cout cout system("pause"); system("cls"); } next=NULL; Phone *pNew,*head,*q;

服务器-azure新手,碰到个初级问题,请各位大侠帮看下

问题描述 azure新手,碰到个初级问题,请各位大侠帮看下 刚刚弄个1元钱的测试账户,在家看看 创建了个虚拟网络,存储账户等等. 也理解了下虚拟网络的用户,基本上就是VPN把local的服务器和放微软家的服务器连起来呗,想象成一个IDC内. 现在在家玩,也没什么vpn不vpn的,反正弄了2个虚拟机. 配置虚拟机的时候没地方选网络的嘛!我要是想给虚拟机增加块网卡怎么弄啊,我看配置修改也只能改CPU和RAM好像? 2.我把一台虚拟机的IP改了,能不能远程了.我看VM的仪表盘里,用来远程的不是应该是公

文件操作-请帮我看一下这个哪里出错了

问题描述 请帮我看一下这个哪里出错了 请帮我看一下这个哪里出错了 关于链表和文件操作的问题 谢谢各位了 解决方案 奇怪, 你的文件中存读的都是指针(Node*), 而不是数据(Node)

gdb调试报了一个什么错误,请帮我看一下

问题描述 gdb调试报了一个什么错误,请帮我看一下 如图,这是什么鬼,大概是什么原因引起的,怎么解决 解决方案 这个原因就是没有生成可以用来调试的可调试文件. 需要在makefile文件中加入 -g 选项. 例如最简单的例子: main:main.cpp g++ -g -o main main.cpp 这样就可以生成可以gdb的main. 可以gdb调试了. 解决方案二: 有关gdb调试watch

java请进,本人小白,这个很简单程序看不懂,单击事件。请帮我讲解一下,就是用AIDE开发的呜呜

问题描述 java请进,本人小白,这个很简单程序看不懂,单击事件.请帮我讲解一下,就是用AIDE开发的呜呜 解决方案 这是android/安卓,和java不是一回事-- 请会安卓的来解答吧 解决方案二: **首先上面的三个private是定义在本类里的私有对象. super.oncreate()方法是默认继承的. 下面的setContentView是将R下面的layout中的newone设为初始布局 三个this.XXX是将上面的对象进行初始化,要不会报空指针异常. btn是个按钮,你的代码是给

paacal-dp 滑雪 请帮我看看我的代码哪里错了 特别是search过程 谢谢!

问题描述 dp 滑雪 请帮我看看我的代码哪里错了 特别是search过程 谢谢! 滑雪是一项非常刺激的运动,为了获得速度,滑雪的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你.给出一个由二维数组表示的滑雪区域,数组的数字代表各点的高度.请你找出这个区域中最长的滑坡. 下面是一个例子: 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 一个人可以从某个点滑向上下左右相邻四个点之一,当且仅当

java-大神帮看下我的代码哪里错了?

问题描述 大神帮看下我的代码哪里错了? 题目是编写程序,读入未指定个数的整数,判断读入的正数和负数分别有多少个,然后计算这些输入值的总和及其平均值(不对0计数).当输入为0时,表明程序结束.将平均值以浮点数显示. import java.util.Scanner; public class TextXXXXX { public static void main (String[] args){ Scanner input = new Scanner(System.in); int count1