23根火柴游戏
发布日期:2021-06-30 22:22:23 浏览次数:3 分类:技术文章

本文共 1598 字,大约阅读时间需要 5 分钟。

Mooc课后习题集 及 做到的一些有趣的题

这是我初学c开始有意识的记录自己做的每一道题开始写下的代码水平 一个一个代码发出来 直到我现在学的数据结构 那个时候还不会注释 格式什么的也是按照自己怎么喜欢怎么来 如果真不会看会代码理解一下 qwq 如代码有错请见谅 毕竟都好久以前敲得了hhh ~~

如果对各位的思路引导有帮助那更好

#include 
int main(){
int i=23,n,computertemp; printf("Game start!\n"); printf("Note: the maximum number is 3\n"); do {
printf("Please enter the number of matches you are moving:\n"); scanf("%d",&n); i-=n; if(n>3 || n<=0 || i<0) {
printf("The number you entered is wrong£¬please re-enter!\n"); i+=n; } else {
printf("The number of matches you are moving is %d:\n",n); printf("The number of matches left is: %d\n",i); if(i==3) {
printf("The number of matches that have been moved by the computer is: %d\n",2); i-=2; printf("The number of matches left is:%d\n",1); } else if(i==2 ||i==1) {
printf("The number of matches that have been moved by the computer is: %d\n",1); printf("The number of matches left is:%d\n",--i); } if(i==0) printf("Congratulations£¡You won!\n"); else {
computertemp=i%3+1; printf("The number of matches that have been moved by the computer is: %d\n",computertemp); i-=computertemp; printf("The number of matches left is:%d\n",i); } fflush(stdin); } }while(i>0); return 0;}

转载地址:https://love6.blog.csdn.net/article/details/110242074 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:最大公约数(哈工大Mooc)
下一篇:平方根表

发表评论

最新留言

哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年04月29日 09时37分20秒