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;
}
查看全文
相关阅读:
arguments.callee
React成长路之--项目搭建
JS判断页面是否被iframe及禁止页面被iframe
flex实现常见布局
移动端 js 实现文章的分页、翻页
移动端开发时,搜索框聚焦时键盘出现“搜索”两字,实现友好操作
JSON详解
50SQL练习
设计模式之单例模式
Spring REST 入门教程
原文地址:https://www.cnblogs.com/feng801/p/1452702.html
最新文章
MAVEN安装和配置
JDK安装和JAVA_HOME配置
Oracle查询易忘点
DatagramSocket(UDP协议)
ServerSocket(TCP/IP协议)__Java
机器学习融合想法记录
shell小笔记
缓存雪崩解决方案记录
pycharm中配置pyspark
git命令
热门文章
ubuntu系统下的docker
numpy的总结
python排序算法的整理
window系统下pycharm的破解配置
window系统mysql无法输入和无法显示中文的处理配置
原生与jQuery封装的ajax请求数据及状态码
React成长路之踩坑路:react-router4路由传参(@react-router4.3.1)
React成长路之踩坑路 Module build failed: SyntaxError: Invalid left-hand side in assignment expression (18:38)
React成长路之踩坑路 Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check
流媒体之视频切片及播放
Copyright © 2011-2022 走看看