哈工大C语言程序设计精髓MOOC慕课 周编程题答案 下载本文

}

int ts=stu[0].scholarship,k; for (i=1;i

if (ts

printf(\ /*

1) 院士奖学金:期末平均成绩高于80分(>80),并且在本学期内发表1篇或1篇以上论文的学生每人均可获得8000元;

2) 五四奖学金:期末平均成绩高于85分(>85),并且班级评议成绩高于80分(>80)的学生每人均可获得4000元;

3) 成绩优秀奖:期末平均成绩高于90分(>90)的学生每人均可获得2000元; 4) 西部奖学金:期末平均成绩高于85分(>85)的西部省份学生每人均可获得1000元;

5) 班级贡献奖:班级评议成绩高于80分(>80)的学生干部每人均可获得850元; */ return 0; }\

\

请编写一个简单的23 根火柴游戏程序,实现人跟计算机玩这个游戏的程序。为了方便程序自动评测,假设计算机移动的火柴数不是随机的,而是将剩余的火柴根数对3求余后再加1来作为计算机每次取走的火柴数。如果计算机打算移走的火柴数等于剩下的火柴数,则将计算机打算移走的火柴数减1。但是计算机不可以不取,剩下的火柴数为1时,必须取走1根火柴。假设游戏规则如下: 1)游戏者开始拥有23根火柴棒;

2)每个游戏者轮流移走1 根、2 根或3 根火柴; 3)谁取走最后一根火柴为失败者。 程序运行结果示例1: Game start!

Note: the maximum number is 3

Please enter the number of matches you are moving: 5↙

The number you entered is wrong,please re-enter! Please enter the number of matches you are moving: 3↙

The number of matches you are moving is:3 The number of matches left is:20

The number of matches that have been moved by the computer is:3 The number of matches left is:17

Please enter the number of matches you are moving: 1↙

The number of matches you are moving is:1 The number of matches left is:16

The number of matches that have been moved by the computer is:2 The number of matches left is:14

Please enter the number of matches you are moving: 2↙

The number of matches you are moving is:2 The number of matches left is:12

The number of matches that have been moved by the computer is:1 The number of matches left is:11

Please enter the number of matches you are moving: 3↙

The number of matches you are moving is:3 The number of matches left is:8

The number of matches that have been moved by the computer is:3 The number of matches left is:5

Please enter the number of matches you are moving: 1↙

The number of matches you are moving is:1 The number of matches left is:4

The number of matches that have been moved by the computer is:2 The number of matches left is:2

Please enter the number of matches you are moving: 1↙

The number of matches you are moving is:1 The number of matches left is:1

The number of matches that have been moved by the computer is:1 The number of matches left is:0 Congratulations!You won! 程序运行结果示例2: 3 3 2 1 3 1

游戏开始提示信息:\

\

提示游戏者输入移动的火柴数:\moving:\\n\

游戏者输入错误数据的提示信息:\,please re-enter!\\n\输入格式: \输出格式:

输出被游戏者移动的火柴数:\ 输出被计算机移动的火柴数:\the computer is:%d\\n\

输出被游戏者或计算机移动后剩余的火柴数:\is:%d\\n\

游戏者获胜的输出提示信息:\!You won!\\n\游戏者失败的输出提示信息:\*/

#include <> main() {

printf(\ int i, j, k, s = 23, n, c; while (1) {

printf(\ scanf(\

if (n<=3 && n>=1 && n<=s){ ; } else{