Advertisement
Ilya_Bykonya

Untitled

Feb 12th, 2024
888
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | Source Code | 0 0
  1. #include <iostream>
  2. #include <random>
  3. #include <chrono>
  4.  
  5. int main() {
  6.     constexpr auto array_size = 10'000;
  7.    int** array = new int*[array_size];
  8.    for(int i = 0; i < array_size; ++i)
  9.        array[i] = new int[array_size];
  10.  
  11.    const auto start = std::chrono::system_clock::now();
  12.    for(int i = 0; i < array_size; ++i) {
  13.        for(int j = 0; j < array_size; ++j) {
  14.            array[j][i] = rand();
  15.        }
  16.    }
  17.    const auto finish = std::chrono::system_clock::now();
  18.  
  19.    std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(finish - start).count() << std::endl;
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement