当前位置: 首页 > news >正文

网站seo文章该怎么写网站建设辶金手指排名十三

网站seo文章该怎么写,网站建设辶金手指排名十三,外网如何访问群晖wordpress,营销型企业网站推广的方法有哪些猜数字 小游戏介绍#xff1a;猜数字游戏是令游戏机随机产生一个100以内的正整数#xff0c;用户输入一个数对其进行猜测#xff0c;需要你编写程序自动对其与随机产生的被猜数进行比较#xff0c;并提示大了#xff0c;还是小了#xff0c;相等表示猜到了。如果猜到猜数字游戏是令游戏机随机产生一个100以内的正整数用户输入一个数对其进行猜测需要你编写程序自动对其与随机产生的被猜数进行比较并提示大了还是小了相等表示猜到了。如果猜到则结束程序。 小游戏实现的功能 1.设置随机数生成1到100的随机数 2.精美的菜单让用户明白怎么操作游戏 3.五次猜机会只有五次猜数字的机会 4.游戏登入页面输入密码登入小游戏 5.自行选择操作用户自行选择玩游戏或者退出游戏 首先来到我们的头文件 #includeiostream//标准输入输出流 #includemalloc.h//动态开辟内存 #includeassert.h//断言 #include Windows.h//改变字体颜色 #includectime//使用time函数 #includeconio.h//使用getch函数 枚举常量 enum Menu {Quit 0,Play 1 }; 小游戏的登入系统 void menu2() {int input 0, count 0, i 0;char mima[20] 123;char shuru[20] { 0 };system(color F4);cout \t\t\t ************************************** endl;cout \t\t\t | *欢迎来到猜数字小游戏* | endl;cout \t\t\t | * * | endl;cout \t\t\t ------------------------------------ endl;cout请输入登入密码endl;while ((count _getch()) ! \r){if (count \b){i--;cout \b \b endl;}else{shuru[i] count;cout*flush; //flush不换行的输出流}}shuru[i] \0;if (strcmp(mima, shuru) 0)//比较字符串的大小{cout \n密码正确您已进入系统 endl;}else{cout 密码错误请重新输入 endl;exit(0);//关闭当前文件}system(pause);system(cls); } 我们的游戏环节 void game() {int r rand() % 100 1;//生成1到100之间的随机数int* ptr (int*)malloc(sizeof(int));assert(ptr);//判断ptr的动态内存有没有开辟成功int count 5;while (count--){cout 请输入你喜欢的数字: endl;cin *ptr;if (*ptr r){cout 你还有 count 次机会 endl;cout 猜大啦 endl;}else{cout 你还有 count 次机会 endl;cout 猜小啦 endl;}if (*ptr r){cout 恭喜你猜对了 endl;break;}if (count 0){cout 很遗憾失败了正确的值为 r endl;}}free(ptr);//释放空间ptr NULL; } 我们的操作菜单 void menu1() {system(color F4);cout |----------------------------------| endl;cout |----------*猜数字游戏*------------| endl;cout |------------1.Play----------------| endl;cout |------------0.Quit----------------| endl;cout |----------------------------------| endl; } 我们的main函数 int main() {menu2();srand((unsigned int)time(NULL));//添加随机数种子利用当前时间作为随机数防止每次随机数都一样int* input (int*)malloc(sizeof(int));assert(input);//判断input的动态内存有没有开辟成功do {system(cls);//清空控制台menu1();cout 请输入当前操作 endl;cin *input;switch (*input){case Quit://枚举类型美化选项cout --------*您已退出游戏*-------- endl;system(pause);break;case Play:game();system(pause);break;default:cout -----------*输入错误重新输入*----------- endl;cin *input;system(pause);}} while (*input);free(input);//释放空间input NULL;return 0; } 以下就是我们猜数字小游戏的整个代码啦 #includeiostream #includemalloc.h #includeassert.h #include Windows.h #includectime #includeconio.h using namespace std; enum Menu {Quit 0,Play 1 }; void menu2() {int input 0, count 0, i 0;char mima[20] 123;char shuru[20] { 0 };system(color F4);cout \t\t\t ************************************** endl;cout \t\t\t | *欢迎来到猜数字小游戏* | endl;cout \t\t\t | * * | endl;cout \t\t\t ------------------------------------ endl;cout请输入登入密码endl;while ((count _getch()) ! \r){if (count \b){i--;cout \b \b endl;}else{shuru[i] count;cout*flush;}}shuru[i] \0;if (strcmp(mima, shuru) 0){cout \n密码正确您已进入系统 endl;}else{cout 密码错误请重新输入 endl;exit(0);}system(pause);system(cls); } void game() {int r rand() % 100 1;int* ptr (int*)malloc(sizeof(int));assert(ptr);int count 5;while (count--){cout 请输入你喜欢的数字: endl;cin *ptr;if (*ptr r){cout 你还有 count 次机会 endl;cout 猜大啦 endl;}else{cout 你还有 count 次机会 endl;cout 猜小啦 endl;}if (*ptr r){cout 恭喜你猜对了 endl;break;}if (count 0){cout 很遗憾失败了正确的值为 r endl;}}free(ptr);ptr NULL; } void menu1() {system(color F4);cout |----------------------------------| endl;cout |----------*猜数字游戏*------------| endl;cout |------------1.Play----------------| endl;cout |------------0.Quit----------------| endl;cout |----------------------------------| endl; } int main() {menu2();srand((unsigned int)time(NULL));int* input (int*)malloc(sizeof(int));assert(input);do {system(cls);menu1();cout 请输入当前操作 endl;cin *input;switch (*input){case Quit:cout --------*您已退出游戏*-------- endl;system(pause);break;case Play:game();system(pause);break;default:cout -----------*输入错误重新输入*----------- endl;cin *input;system(pause);}} while (*input);free(input);input NULL;return 0; }
http://www.zqtcl.cn/news/410170/

相关文章:

  • seo怎么给网站做外链受欢迎的网站建设教程
  • 网站建设使用多语言河南电商网站设计
  • 网站搭建有免费的吗网站地图生成代码
  • 建设公司网站要注意什么投资小利润高的小生意
  • 网站建设需要做哪些工作做胃镜需那好天津津门网站A
  • 做网站申请域名的流程辽宁省工程造价网
  • 网站系统维护一般多长时间金华高端网站设计
  • 做网站公司销售开场白企业网站规划与开发
  • 兰州新区建站不锈钢网站建设
  • 淘宝小网站怎么做的电商网站有哪些
  • 哪些网站可以做画赚钱wordpress go跳转页
  • 怎么做新网站上线通稿深圳罗湖区网站建设公司
  • php 企业网站做网站可以赚钱吗
  • 局域网视频网站建设点播系统长沙3合1网站建设价格
  • 静态网站 服务器合肥做个网站什么价格
  • 宁阳网站设计家电网站设计方案
  • 网站备案icp秦皇岛黄金海岸
  • dedecms 金融类网站模板wordpress dux5.3
  • 学校网站源码wordpress向网站上传文件怎么做
  • 电子商务网站建设说课稿济南网站建设方案报价
  • 谈谈设计和建设网站体会wordpress header在哪
  • 360免费建站怎么进不去域名托管
  • 做网站视频存储网站建设有云端吗
  • 建网站如何上传南通 网站优化
  • 青海学会网站建设公司果汁网站模板
  • 10_10_网站建站怎么做网站链接支付
  • 九台网站甘肃网站优化
  • phpcms 网站源码建设银行科技中心网站首页
  • 营销型网站建设php源码无锡设计网站公司
  • 在线制作简历的网站绍兴seo全网营销