zoukankan
html css js c++ java
快速生成10亿随机不重复数据代码(转)
#include
<
cstdlib
>
#include
<
iostream
>
#include
<
windows.h
>
using
namespace
std;
char
map2char[]
=
{
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
,
'
5
'
,
'
6
'
,
'
7
'
,
'
8
'
,
'
b
'
,
'
c
'
,
'
d
'
,
'
e
'
,
'
f
'
,
'
g
'
,
'
h
'
,
'
i
'
,
'
j
'
,
'
k
'
,
'
l
'
,
'
m
'
,
'
n
'
,
'
o
'
,
'
p
'
,
'
q
'
,
'
r
'
,
'
s
'
,
'
t
'
,
'
u
'
,
'
v
'
,
'
w
'
,
'
x
'
,
'
y
'
}
;
void
getbit( unsigned e,
char
*
s,
int
offset )
{
int
i
=
17
;
while
( i
>=
0
)
{
s[
18
*
offset
+
i]
=
((e
>>
i)
&
1
);
--
i;
}
}
int
main(
int
argc,
char
*
argv[])
{
srand(GetTickCount());
char
bit[
90
], S[
90
];
for
(
int
i
=
0
; i
<
sizeof
(bit);
++
i ) bit[i]
=
0
, S[i]
=
0
;
unsigned x, T;
for
(
int
k
=
0
; k
<
5
;
++
k )
{
do
x
=
rand();
while
( x
==
0
);
getbit( x, S, k);
getbit( x, bit, k );
}
unsigned head
=
89
;
unsigned j
=
0
, time
=
GetTickCount(), Max
=
1000000
;
do
{
++
j;
T
=
(bit[head]
&
1
)
^
(bit[(head
-
83
)
%
90
]
&
1
)
^
(bit[(head
-
84
)
%
90
]
&
1
)
^
(bit[(head
-
86
)
%
90
]
&
1
)
^
(bit[(head
-
89
)
%
90
]
&
1
);
bit[head]
=
T;
head
=
(head
+
1
)
%
90
;
for
(
int
index
=
0
; index
<
18
;
++
index )
{
int
num
=
0
;
for
(
int
j
=
0
; j
<
5
;
++
j )
num
+=
(bit[(head
+
5
*
index
+
j)
%
90
]
==
0
)
?
0
: (
1
<<
j);
cout
<<
map2char[num];
}
cout
<<
endl;
}
while
( j
<
Max );
cout
<<
"
time:
"
<<
GetTickCount()
-
time
<<
"
ms!\n
"
;
system(
"
PAUSE
"
);
return
EXIT_SUCCESS;
}
查看全文
相关阅读:
matlab std函数 用法及实例
Matlab基本用法
MATLAB — axis
Matlab——plot polyfit polyval
matlab知识点汇集
Android环境搭建
ipipe 环境下gpio中断产生死机的信息
烧写AT91Bootstrap不能连接SAM-BA的解决方法
u-boot 编译时间
9x25 串口映射
原文地址:https://www.cnblogs.com/feng801/p/1452702.html
最新文章
Maven上传构建到私服
代码直连指定ip的dubbo服务
centos服务器如何用命令查看哪个程序内存占用情况,硬盘空间占用
linux脚本后台运行
使用linux的shell脚本实现在当前行重复动态显示时间等字符串信息(不另起新行)
Choose unique values for the 'webAppRootKey' context-param in your web.xml files!
Redis脚本
使用 CXF 做 webservice 简单例子
maven打包配置
linux部署java命令
热门文章
关于@Autowired后Spring无法注入的问题
Mysql order by与limit混用陷阱
springboot2.X访问静态文件配置
java可供判断某字符串是什么编码的一行代码
Java 按字节获得字符串(中文)长度
使用isEmpty()报空指针异常
单片机知识点
使用STC-ISP向KEIL添加STC芯片头文件
Matlab查看数值不用科学计数法显示
Matlab函数——std,std2与mean,mean2区别
Copyright © 2011-2022 走看看