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

内容发布更新时间 : 2024/12/22 15:26:23星期一 下面是文章的全部内容请认真阅读。

{

printf(\ int n,i;

scanf(\ WIN stu[n]; for (i=0;i

printf(\

printf(\

printf(\printf(\

printf(\printf(\ stu[i].scholarship=0;

if (stu[i].finalScore>80 && stu[i].paper >=1) stu[i].scholarship+=8000; if

(stu[i].finalScore>85

&&

stu[i].classScore>

80)

stu[i].scholarship+=4000;

if (stu[i].finalScore>90) stu[i].scholarship+=2000;

if (stu[i].finalScore>85 && stu[i].west=='Y') stu[i].scholarship+=1000; if (stu[i].classScore> 80 && stu[i].work=='Y') stu[i].scholarship+=850; printf(\ }

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; }\12.3 \/*

请编写一个简单的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

游戏开始提示信息:\

\

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

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