回答編集履歴
1
追記
answer
CHANGED
@@ -1,1 +1,29 @@
|
|
1
|
-
int Array[32768] の中からデタラメにひとつ取り出すため、何番目を取り出せばいいかを表すデタラメな15bit-int(0~32767)を作るには? って訊いてる?
|
1
|
+
int Array[32768] の中からデタラメにひとつ取り出すため、何番目を取り出せばいいかを表すデタラメな15bit-int(0~32767)を作るには? って訊いてる?
|
2
|
+
|
3
|
+
[追記] srand/rand なんか使わない。
|
4
|
+
|
5
|
+
```C++
|
6
|
+
#include <iostream>
|
7
|
+
#include <random>
|
8
|
+
#include <functional>
|
9
|
+
|
10
|
+
int main() {
|
11
|
+
using namespace std;
|
12
|
+
|
13
|
+
// 範囲0~32767の一様乱数
|
14
|
+
// メルセンヌ・ツイスターの'種'は省略。好きに埋めておくれ。
|
15
|
+
auto rand = bind(uniform_int_distribution<int>(0, 32767), mt19937());
|
16
|
+
|
17
|
+
const int N = 35;
|
18
|
+
int Array[N];
|
19
|
+
|
20
|
+
// randを使って埋める
|
21
|
+
generate_n(Array, N, rand);
|
22
|
+
|
23
|
+
// デキタカナ?
|
24
|
+
for ( int item : Array ) {
|
25
|
+
cout << item << ' ';
|
26
|
+
}
|
27
|
+
cout << endl;
|
28
|
+
}
|
29
|
+
```
|