Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Copy double[2][3] into vector<vector<double>>
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86 #include <cstddef> #include <algorithm> #include <iostream> #include <iterator> #include <vector> #define DIMENSION(array) (sizeof(array) / sizeof(array[0])) int main() { double arr[2][3] = {{33, 55, 77}, {2, 8, 5}}; std::vector<std::vector<double>> vec(DIMENSION(arr)); for (std::size_t i = 0; i < DIMENSION(arr); ++i) { vec[i].reserve(DIMENSION(arr[i])); // optional vec[i].assign(std::cbegin(arr[i]), std::cend(arr[i])); } std::ostream_iterator<double> cout_iter(std::cout, " "); for (const auto& v : vec) { std::copy(std::cbegin(v), std::cend(v), cout_iter); std::cout << '\n'; } }
cl.exe
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 1.78 sec, absolute running time: 0.43 sec, absolute service time: 2,29 sec
edit mode
|
history
|
discussion
33 55 77 2 8 5