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;
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 two 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语言课程设计很快就结束了,回想这一周,几分欣喜,几分紧张,欣喜的是学了C语言能得到应用,紧张的是怕自己不能更好的设计自己的程序,生怕自己设计的程序不能顺利的完成。不过在老师的帮助下,在我们组员的共同的努力下,我们能很好而顺利的将程序设计并且运行出来,虽然有几处不足但在老师的改正下我们的程序也得到了完善。
通过这一周的C语言课程设计,我懂得了很多,它让我知道做事情需要认真与细心,需要耐心与恒心。就拿我们的程序来说把,起初做完运行后有很多错误,当时我们组每个人都非常焦虑,的确,看着长长的程序想要去一一把问题解决也并非是件简单的事,但如果你静下心来细心的去找就会把错误一个一个的找出来。还有一点是非常重要的,那就是有不懂的地方及时向老师提问,那样的话你就会对不懂的地方有个深刻的理解,以后再碰到此类问题自己也就能解决了。所以我们的程序是在老师的帮助下,在我们组成员的耐心的查找与改正下完成的。我们的成功离不开老师的指导,离不开我们的共同努力。看着运行出来的程序我们笑了,真的,当时的心情真的想不出用哪个词语去形容,也许笑容代表了一切。
短短的几天时间让我对C语言有了一个全新的概念,它不仅是一门课程,更是一门技术。也使我领会到实践的重要性,我希望在以后的学习生活中我会有更多的实践机会来提高我的思考能力与动手能力,培养我的细心、耐心与恒心。这是难忘的一次实训课程,它会在我的人生旅途中写上浓重的一笔。感谢老师的指导帮助,感谢同组兄弟的支持,谢谢! 未来的社会必将是科学技术全面,全面发展的社会,我们需要更应该懂得并掌握现代化的科学知识,C语言是一门全新的课程,也许当我们初次接触这门课程会感觉到新鲜,当你更加深入的学习它你会体会到它的乐趣与方便,而未来的社会也正需要全能型的人才,让我们共同努力吧,学会更多的知识技术,为了美好的未来而加油!
课程设计是培养学生综合运用所学知识,发现,提出,分析和解决实际问题,锻炼实践能力的重要环节,是对学生实际工作能力的具体训练和考察过…
课程设计总结经过一个学期对《C++程序设计》的学习,我学习到了基本的理论知识,了解到了C++语言程序设计的思想,这些知识都为我的课…
《化工原理课程设计》总结本学期顺利完成了化学工程与工艺专业共100名同学的化工原理课程设计,总体来看学生的工艺计算、过程设计及绘图…
PLC自动门课程设计心得体会:通过此次C语言程序设计实践本人实在是获益不浅!C语言是上个学期开的课程所以这个学期并没怎么看过当要开…
课程设计心得体会在初学C语言的一个学期后,学校组织我们进行了C语言实训,尝试编写一些有难度的程序。在为期两周的时间中,同组同学共同…
课程设计是培养学生综合运用所学知识,发现,提出,分析和解决实际问题,锻炼实践能力的重要环节,是对学生实际工作能力的具体训练和考察过…
Android应用设计实验报告学院:专业:通信工程班级:姓名:学号:100312107指导教师:20xx年x月x日天气查询1.关键…
通过2周的施工组织实训,让我对自己一个深入了解,知识面不宽,基础知识大大的欠缺,不断的上网查资料和翻阅相关书籍来完成本次实训任务,…
数字逻辑电路课程设计实验总结报告题目一:用J-K触发器设计13进制加法计数器一、设计过程:参见设计实验报告(真值表,卡诺图)。二、…
科研训练个人总结题目:“学生姓名:学院:信息工程学院班级:软件11-3指导教师:20xx年x月x日个人总结在这次的科研训练中感觉到…