C语言中如何生成1~100的随机数(附代码) #include<stdio.h>#include<time.h>#include<process.h>#include<stdlib.h>#include<windows.h>int main() { int ret = 0; int guess = 0; int left = 0; int right = 100; srand((unsigned int)time(NULL)); ret = rand() % 100; printf(“提供的答案数是->%d ”,ret); guess = 50; while (1) { if (guess > ret) { printf(“猜大了->%d ”, guess); right = guess; guess = (right + left) / 2; Sleep(1000); } else if (guess %d ”, guess); left = guess; guess = (right + left) / 2; Sleep(1000); } if (guess == ret) { printf(“猜到了是%d”, guess); break; } } system(“pause “); return 0; }</windows.h></stdlib.h></process.h></time.h></stdio.h>登录后复制
2024最新激活全家桶教程,稳定运行到2099年,请移步至置顶文章:https://sigusoft.com/99576.html
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。 文章由激活谷谷主-小谷整理,转载请注明出处:https://sigusoft.com/85943.html