Advertisement
cd62131

Simple Matrix

Feb 13th, 2014
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <chrono>
  2. #include <iostream>
  3. #include <random>
  4. #include <vector>
  5. using namespace std;
  6. void foo(vector<double> a, int n) {
  7.   int i = 0;
  8.   for (auto& e : a) {
  9.     cout << e << ' ';
  10.     if (++i % n == 0) cout << endl;
  11.   }
  12. }
  13. int main() {
  14.   int n;
  15.   cin >> n;
  16.   mt19937 g(chrono::system_clock::now().time_since_epoch().count());
  17.   uniform_real_distribution<double> rnd(0., 1.);
  18.   vector<double> box(n * n);
  19.   for (auto& e : box)
  20.     e = rnd(g);
  21.   foo(box, n);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement