李子的猜数游戏!(已更新!)
猜数游戏
最近闲来无事,便随便做了个猜数游戏,话不多说,上代码!
(已更新!!!时间为2020-1-8)
(已更新!!!时间为2020-1-17本次更新γ版)
(在这我就不写γ版的代码了,乱,去另一条博客看)
(γ版地址:https://blog.csdn.net/qing_dao_boy/article/details/104020816)
(2020/5/18更新,地址为https://blog.csdn.net/qing_dao_boy/article/details/106198877)
(已更新!epsilon版,这位作者(就是我)并不想公开代码~ )
首先进行库处理
Ctrl+click< iostream >
打开如下代码
// Standard iostream objects -*- C++ -*-// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>./** @file include/iostream* This is a Standard C++ Library header.*///
// ISO C++ 14882: 27.3 Standard iostream objects
//#ifndef _GLIBCXX_IOSTREAM
#define _GLIBCXX_IOSTREAM 1#pragma GCC system_header#include <bits/c++config.h>
#include <ostream>
#include <istream>namespace std _GLIBCXX_VISIBILITY(default)
{_GLIBCXX_BEGIN_NAMESPACE_VERSION/*** @name Standard Stream Objects** The <iostream> header declares the eight <em>standard stream* objects</em>. For other declarations, see* http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch24.html* and the @link iosfwd I/O forward declarations @endlink** They are required by default to cooperate with the global C* library's @c FILE streams, and to be available during program* startup and termination. For more information, see the HOWTO* linked to above.*///@{extern istream cin; /// Linked to standard inputextern ostream cout; /// Linked to standard outputextern ostream cerr; /// Linked to standard error (unbuffered)extern ostream clog; /// Linked to standard error (buffered)#ifdef _GLIBCXX_USE_WCHAR_Textern wistream wcin; /// Linked to standard inputextern wostream wcout; /// Linked to standard outputextern wostream wcerr; /// Linked to standard error (unbuffered)extern wostream wclog; /// Linked to standard error (buffered)
#endif//@}// For construction of filebuffers for cout, cin, cerr, clog et. al.static ios_base::Init __ioinit;_GLIBCXX_END_NAMESPACE_VERSION
} // namespace#endif /* _GLIBCXX_IOSTREAM */
改为:
// Standard iostream objects -*- C++ -*-// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>./** @file include/iostream* This is a Standard C++ Library header.*///
// ISO C++ 14882: 27.3 Standard iostream objects
//#ifndef _GLIBCXX_IOSTREAM
#define _GLIBCXX_IOSTREAM 1#pragma GCC system_header#include <bits/c++config.h>
#include <ostream>
#include <conio.h>
#include <cstdio>
#include <cstring>
#include <windows.h>
#include <cstdlib>
#include <time.h>
#include <istream>namespace std _GLIBCXX_VISIBILITY(default)
{_GLIBCXX_BEGIN_NAMESPACE_VERSION/*** @name Standard Stream Objects** The <iostream> header declares the eight <em>standard stream* objects</em>. For other declarations, see* http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch24.html* and the @link iosfwd I/O forward declarations @endlink** They are required by default to cooperate with the global C* library's @c FILE streams, and to be available during program* startup and termination. For more information, see the HOWTO* linked to above.*///@{extern istream cin; /// Linked to standard inputextern ostream cout; /// Linked to standard outputextern ostream cerr; /// Linked to standard error (unbuffered)extern ostream clog; /// Linked to standard error (buffered)#ifdef _GLIBCXX_USE_WCHAR_Textern wistream wcin; /// Linked to standard inputextern wostream wcout; /// Linked to standard outputextern wostream wcerr; /// Linked to standard error (unbuffered)extern wostream wclog; /// Linked to standard error (buffered)
#endif//@}// For construction of filebuffers for cout, cin, cerr, clog et. al.static ios_base::Init __ioinit;_GLIBCXX_END_NAMESPACE_VERSION
} // namespace#endif /* _GLIBCXX_IOSTREAM */
保存,接下来就可以用以下的代码了。(这是1.0α版本,如果要β版,请往下翻或去我的另一条博客,这里贴上网址https://blog.csdn.net/qing_dao_boy/article/details/103897462)
#include<iostream>
using namespace std;
//
void pause()
{cout<<"请按任意键退出本程序......"; getch();exit (0);
}
int main()
{cout<<"欢迎来到由李子开发的猜数游戏1.0α(alpha)版本!!!!!"<<" /"<<"(*^▽^*)/"<<endl;cout<<"你要不要玩呢???(Y/N)"<<endl;char choose;while(1){cin>>choose;if(choose=='Y'||choose=='y'){break; }else if(choose=='N'||choose=='n'){cout<<"好吧,ヾ(ToT)Bye~Bye~";exit (0); }else{cout<<"无效选择!请重选!";continue;}}cout<<"好的!接下来,请选择级别"<<endl<<"1、简单(10次机会,0~50内的数字)"<<endl<<"2、中等(8次机会,0~100内的数字)"<<endl<<"3、高级(7次机会,0~200内的数字)"<<endl<<"4、困难(只有3次机会,0~500内的数字)"<<endl;int choose1=0;int truenum=0;int num=0;cin>>choose1; if(choose1==1){cout<<"------游戏开始------"<<endl; srand((unsigned)time(NULL));truenum=rand() % 50;cout<<"开始吧!"<<endl;int opportunities_easy=10; while(opportunities_easy!=0){cout<<"你还有"<<opportunities_easy<<"次机会"<<endl; cin>>num;if(truenum==num){cout<<"你太牛了!对了!";pause();return 0;}else{/*cout<<"错了!";opportunities_easy--;*/if(num<truenum){cout<<"小了!"<<endl; opportunities_easy--;}else{cout<<"大了!"<<endl;opportunities_easy--;}}}cout<<"没机会了!!自动退出!"<<endl;pause();return 0;} else if(choose1==2){cout<<"------游戏开始------"<<endl; srand((unsigned)time(NULL));truenum=rand() % 100;cout<<"开始吧!"<<endl;int opportunities_secondary=8;while(opportunities_secondary!=0){cout<<"你还有"<<opportunities_secondary<<"次机会"<<endl; cin>>num;if(truenum==num){cout<<"你太牛了!对了!"<<endl;return 0;pause();}else{/*cout<<"错了!"<<endl;opportunities_secondary--;*/if(num<truenum){cout<<"小了!"<<endl; opportunities_secondary--;}else{cout<<"大了!"<<endl;opportunities_secondary--;}}}cout<<"没机会了!!自动退出!"<<endl;pause();return 0;}else if(choose1==3){cout<<"------游戏开始------"<<endl; srand((unsigned)time(NULL));truenum=rand() % 100;cout<<"开始吧!"<<endl;int opportunities_senior=7;while(opportunities_senior!=0){cout<<"你还有"<<opportunities_senior<<"次机会"<<endl; cin>>num;if(truenum==num){cout<<"你太牛了!对了!"<<endl;pause();return 0;}else{/*cout<<"错了!"<<endl;opportunities_senior--;*/if(num<truenum){cout<<"小了!"<<endl; opportunities_senior--;}else{cout<<"大了!"<<endl;opportunities_senior--;}}}cout<<"没机会了!!自动退出!"<<endl;pause();return 0;}else{cout<<"------游戏开始------"<<endl; srand((unsigned)time(NULL));truenum=rand() % 100;cout<<"开始吧!"<<endl;int opportunities_difficulty=3;while(opportunities_difficulty!=0){cout<<"你还有"<<opportunities_difficulty<<"次机会"<<endl; cin>>num;if(truenum==num){cout<<"挖槽,困难竟然对了,啊啊啊啊啊啊啊!你太牛了!"<<endl;pause();pause();return 0;}else{/*cout<<"错了!"<<endl;opportunities_difficulty--;*/if(num<truenum){cout<<"小了!"<<endl; opportunities_difficulty--;}else{cout<<"大了!"<<endl;opportunities_difficulty--;}}}cout<<"没机会了!!自动退出!"<<endl;pause();return 0;}return 0;
}
/*THIS IS NOT COMPLINING OF GCC,PLEASE OPEN GCC COPLINING.
这是没有 使用GCC编译器编译过的,请打开GCC编译.
LZGZS
李子工作室
ben-lz
本-李子
----THANK YOU----
----谢谢----
*/
(这是1.0β版本)
#include<iostream>
using namespace std;
void pause()
{cout<<"请按任意键退出本程序......"; getch();exit (0);
}
int main()
{cout<<"欢迎来到由李子开发的猜数游戏1.0β(beta)版本!!!!!"<<" /"<<"(*^▽^*)/"<<endl<<"本次更新了教程!"<<" /"<<"(*^▽^*)/"<<endl;cout<<"你要不要玩呢???(Y/N)"<<endl;char choose;while(1){cin>>choose;if(choose=='Y'||choose=='y'){break; }else if(choose=='N'||choose=='n'){cout<<"好吧,ヾ(ToT)Bye~Bye~";exit (0); }else{cout<<"无效选择!请重选!";continue;}}cout<<"好的!接下来,请选择级别"<<endl<<"1、萌新(教学)"<<endl<<"2、简单(10次机会,0~50内的数字)"<<endl<<"3、中等(8次机会,0~100内的数字)"<<endl<<"4、高级(7次机会,0~200内的数字)"<<endl<<"5、困难(只有3次机会,0~500内的数字)"<<endl;int choose1=0;int truenum=0;int num=0;cin>>choose1; if(choose1==1){cout<<"你进入了教学!"<<endl<<"这是一个猜数游戏,除去教学共4个级别,按0开始教学"<<endl;int u=0;cin>>u;cout<<"------游戏开始------"<<endl; srand((unsigned)time(NULL));truenum=rand() % 50;cout<<"现在已经生成了一个0~50的随机数,你需要将这个随机数输入,如果错误将提示,简单共10次机会。"<<endl; cout<<"开始吧!"<<endl;int opportunities_easy=10; while(opportunities_easy!=0){cout<<"你还有"<<opportunities_easy<<"次机会"<<endl<<"你一定要注意机会,机会用光将自动退出!"; cin>>num;if(truenum==num){cout<<"你太牛了!对了!"<<"重新打开这个程序,体验一下吧!";pause();return 0;}else{/*cout<<"错了!";opportunities_easy--;*/if(num<truenum){cout<<"小了!"<<endl<<"你猜的数比答案小,请猜一个大点的qwq"; opportunities_easy--;cout<<"你的机会已经-1了!请注意机会!"<<endl; }else{cout<<"大了!"<<"你猜的数比答案大,请猜一个小点的qwq"<<endl;opportunities_easy--;cout<<"你的机会已经-1了!请注意机会!"<<endl;}}}cout<<"没机会了!!自动退出!"<<endl<<"好吧,你太*了,再来一次教学吧!";pause();return 0;}else if(choose1==2){cout<<"------游戏开始------"<<endl; srand((unsigned)time(NULL));truenum=rand() % 50;cout<<"开始吧!"<<endl;int opportunities_easy=10; while(opportunities_easy!=0){cout<<"你还有"<<opportunities_easy<<"次机会"<<endl; cin>>num;if(truenum==num){cout<<"你太牛了!对了!";pause();return 0;}else{/*cout<<"错了!";opportunities_easy--;*/if(num<truenum){cout<<"小了!"<<endl; opportunities_easy--;}else{cout<<"大了!"<<endl;opportunities_easy--;}}}cout<<"没机会了!!自动退出!"<<endl;pause();return 0;} else if(choose1==3){cout<<"------游戏开始------"<<endl; srand((unsigned)time(NULL));truenum=rand() % 100;cout<<"开始吧!"<<endl;int opportunities_secondary=8;while(opportunities_secondary!=0){cout<<"你还有"<<opportunities_secondary<<"次机会"<<endl; cin>>num;if(truenum==num){cout<<"你太牛了!对了!"<<endl;return 0;pause();}else{/*cout<<"错了!"<<endl;opportunities_secondary--;*/if(num<truenum){cout<<"小了!"<<endl; opportunities_secondary--;}else{cout<<"大了!"<<endl;opportunities_secondary--;}}}cout<<"没机会了!!自动退出!"<<endl;pause();return 0;}else if(choose1==4){cout<<"------游戏开始------"<<endl; srand((unsigned)time(NULL));truenum=rand() % 100;cout<<"开始吧!"<<endl;int opportunities_senior=7;while(opportunities_senior!=0){cout<<"你还有"<<opportunities_senior<<"次机会"<<endl; cin>>num;if(truenum==num){cout<<"你太牛了!对了!"<<endl;pause();return 0;}else{/*cout<<"错了!"<<endl;opportunities_senior--;*/if(num<truenum){cout<<"小了!"<<endl; opportunities_senior--;}else{cout<<"大了!"<<endl;opportunities_senior--;}}}cout<<"没机会了!!自动退出!"<<endl;pause();return 0;}else{cout<<"------游戏开始------"<<endl; srand((unsigned)time(NULL));truenum=rand() % 100;cout<<"开始吧!"<<endl;int opportunities_difficulty=3;while(opportunities_difficulty!=0){cout<<"你还有"<<opportunities_difficulty<<"次机会"<<endl; cin>>num;if(truenum==num){cout<<"挖槽,困难竟然对了,啊啊啊啊啊啊啊!你太牛了!"<<endl;pause();pause();return 0;}else{/*cout<<"错了!"<<endl;opportunities_difficulty--;*/if(num<truenum){cout<<"小了!"<<endl; opportunities_difficulty--;}else{cout<<"大了!"<<endl;opportunities_difficulty--;}}}cout<<"没机会了!!自动退出!"<<endl;pause();return 0;}return 0;
}
/*THIS IS NOT COMPLINING OF GCC,PLEASE OPEN GCC COPLINING.
这是没有 使用GCC编译器编译过的,请打开GCC编译.
LZGZS
李子工作室
ben-lz
本-李子
----THANK YOU----
----谢谢----
*/
PS:这个可以使用Dev-cpp编译,我用的是Dev-cpp5.9.2版,如用VS或VC[++],可以把using namespace std;
删掉,可编译,可运行,如有不足,请多多指教!
李子的猜数游戏!(已更新!)相关推荐
- 李子的猜数游戏!!!!!!!!!!!!!!!!(δ版)
李子的猜数游戏 时隔四月,我的猜数游戏已经尘封已久,我终于再一次拂去了他的灰尘,开始了这次更新(简单说就是老子好久没更新了) 好了,为了弥补拖更,我将猜数游戏编到了δ版.哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈 ...
- 李子的猜数游戏!(β版)
猜数游戏 最近闲来无事,便随便做了个猜数游戏,话不多说,上代码! (已更新!!!) 首先进行库处理 Ctrl+click< iostream > 打开如下代码 // Standard io ...
- 李子的猜数游戏!!!γ版
γ(紧急修复)版为: #include<iostream> using namespace std; void pause() {cout<<"请按任意键退出本程序. ...
- 李子的猜数游戏delta1.1紧急修复版本
xdm,出大问题 我的delta1.0版本的猜数游戏的教学模式出了亿点点bug,现在进行修正: delta1.1版本最终代码为: #include<iostream>#include< ...
- 李子的猜数游戏!!!!!epsilon1.0!
哈喽兄弟们!这里又是我的猜数游戏! 在经历了上一次的代码丢失之后,我痛定思痛,把猜数游戏用两年做了出来(痛,太痛了!) 那么,今天我们就来更新!不多比比,上代码!! #include<iostr ...
- 【Rust指南】配置加速Cargo下载、更新依赖库|利用随机数编写Rust猜数游戏
文章目录 前言 一.Cargo配置问题与VSC的实用插件下载 1.解决Cargo拉取crates.io非常慢的问题 2.VSC自动管理Rust项目的实用插件 二.编写Rust 的猜数游戏 1.抓取 ...
- 微课|中学生可以这样学Python(例11.2):tkinter猜数游戏(1)
适用教材: 董付国,应根球.<中学生可以这样学Python>.清华大学出版社,2017. 第11章 综合案例设计与分析 例11.2 tkinter版猜数游戏 京东购买链接:https: ...
- 微课|中学生可以这样学Python(例11.2):tkinter猜数游戏(2)
适用教材: 董付国,应根球.<中学生可以这样学Python>.清华大学出版社,2017. 第11章 综合案例设计与分析 例11.2 tkinter版猜数游戏 京东购买链接:https: ...
- 微课|中学生可以这样学Python(例11.2):tkinter猜数游戏(3)
适用教材: 董付国,应根球.<中学生可以这样学Python>.清华大学出版社,2017. 第11章 综合案例设计与分析 例11.2 tkinter版猜数游戏 京东购买链接:https: ...
最新文章
- linux定时任务_从零开始学Linux运维|41.定时任务crontab
- 奥威软件大数据bi_哪家BI软件能做Sql server的数据可视化分析?
- 三菱fx2n做从站的modbus通讯_三菱PLC编程多种电缆接线图,收藏向!
- 字典攻击——彩虹表攻击与防御
- 在线英文翻译中文比较
- 西北大学计算机课表,西北大学课表
- 人体姿态估计-CPN(三)
- 关闭IDEA提示 empty tag doesn't work in some browsers(设置inspections)
- R语言|Rstudio|初学笔记
- 主轴承盖螺栓拧紧机PLC控制程序
- PCLint使用介绍
- reddit_如何减少Reddit的吸吮
- 国产服务器飞腾/鲲鹏/龙芯下Linux(统信UOS、麒麟系统)下GB28181/Onvif/RTSP监控视频平台的部署操作
- 方形图片转为圆形图片
- 【idea文件夹右键新建,没有Java Class选项】
- MessageBox和::MessageBox的使用
- 6脚自锁开关内部结构
- linux scp 指令使用
- OSChina 周四乱弹 ——遇上色狼后辣椒水的妙用!
- 2007中国手机客户端软件TOP50
热门文章
- 【观察】戴尔科技首发Azure Stack HCI,背后的大势、胜势与升势
- 字体大小和网页像素之间的关系
- LInux7系统支持华硕H81,华硕h81主板bios设置方法步骤
- “S“型曲线加减速在42步进电机的位置控制和速度控制中的交叉应用
- linux 绝对路径root,绝对路径和相对路径及cd、pwd、mkdir、rmdir、tree命令
- c语言计算特殊角的正弦值,特殊角的三角函数值表 常用的正余弦函数值
- 26张图讲解HTTP,不信你还不会
- 关于uni-app获取设备的iccid
- 善用Google搜索,资源唾手可得
- [-128,127]内十进制转二进制