qq_33701809 2016-01-29 09:26 采纳率: 33.3%
浏览 2436
已结题

大神请进,帮小孩看一下他的算法,点评点评。

问题如下:
图片说明
图片说明

算法如下:

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

  • 写回答

6条回答

  • devmiao 2016-01-29 14:32
    关注

    建议你去外语学院问,这个和编程没关系了。

    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置