C++拾遗 记录一些C++常见问题 获得0-100的随机数 12345678910111213#include <iostream>#include <vector>#include <cstdlib>#include <ctime>using namespace std;int main(){ srand((int)time(0)); // 产生随机种子 把0换成NULL也行 int targetNumber = rand() % 100; cout << "target number is " << targetNumber << endl; system("pause"); return 0;} C++ 本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处! C++后台开发 核心技术与应用实践 第一章 上一篇 LeetCode统计的面试高频题目 下一篇 Please enable JavaScript to view the comments powered by Disqus.