#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
const int n = ;
/*cstdlib头文件要和ctime一起,否则无法使用srand*/
void RandBetween(int s, int d, int num)
{
int result;
srand((unsigned)time(NULL));
for(int i=; i<num; i++)
{
result = rand() % (d - s) + s + ;// (s,d]
result = rand() % (d - s) + s;// [s,d)
result = rand() % (d - s + ) + s;// [s,d]
cout << result << endl;
}
} int main()
{
int first, second;
cout << "input start and end: ";
cin >> first >> second;
RandBetween(first, second, n);
return ;
}
相关文章
- FZU:1759-Problem 1759 Super A^B mod C (欧拉降幂)
- python 应用 base64、hmac、hashlib包实现:MD5编码 base64编码解码、SHA256编码、urlsafe_b64encode编码等等基本所有的加密签名的方法
- Oracle-left join两表关联只取B表匹配到的第一条记录【over partition by(分组后对组内数据排序)】
- Oracle两表关联,只取B表的第一条记录
- [b0013] Hadoop 版hello word mapreduce wordcount 运行(三)
- 【转载】 H264的I/P/B帧类型判断
- 中兴云电脑W102D_晶晨S905X2_2+16G_mt7661无线_安卓9.0_线刷固件包-备用链接: 链接:https://wws.lanzoux.com/b021tgeng 提取码:ebbi
- xcode报错:Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/b
- Educational Codeforces Round 31 B. Japanese Crosswords Strike Back【暴力】
- 树梅派3B kali2.0 启用SSH进行远程登录