Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <random>
- int main()
- {
- int matrix[3][3] = { 0 };
- // 乱数
- std::random_device rnd;
- std::mt19937 mt(rnd());
- std::uniform_int_distribution<> dist(1, 100);
- // 乱数を配列に格納
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- matrix[i][j] = dist(mt);
- }
- }
- // 配列に格納した配列を表示
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- std::cout << "matrix[" << i << "][" << j << "] = " << matrix[i][j] << " ";
- }
- std::cout << std::endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement