“Inisialisasi vektor 2D” Kode Jawaban

cara menginisialisasi vektor 2D di c

#include <iostream>
#include <vector>
#include <algorithm>
 
int main()
{
    std::vector<int> v = {2, 1, 3, 6, 7, 9, 8};
 
    int max = *max_element(v.begin(), v.end());
    int min = *min_element(v.begin(), v.end());
 
    std::cout << min << ", " << max << std::endl;        // 1, 9
 
    return 0;
}
Nkabinde Nduduzo

cara menginisialisasi vektor 2D

To be used in DP problems:

vector<vector<int>>dp; //global init

dp = vector<vector<int>>(n,vector<int>(m,0)); // local init for test cases
where,
	n, m = dimensions of matrix
Viper

inisialisasi vektor 2D ints c

auto M = 4;	// num of rows
auto N = 3; // num of cols in each row
auto default_value = 1; // default value of all int elements
std::vector<std::vector<int>> matrix(M, std::vector<int>(N, default_value));
Anxious Alligator

Inisialisasi vektor 2D di CPP

vector<vector<int>> vec( n , vector<int> (m, 0));

where: n is number of ROWS,
	   m is number of COLUMNS
       
So result will be ( Let n = 2, m = 3 )
  	[[ 0, 0, 0],
     [ 0, 0, 0]]
     		   ( 2 x 3 )
Concerned Cheetah

Menginisialisasi vektor 2D

vector<vector<int> > vec( n , vector<int> (m, 0));
deadman

Inisialisasi vektor 2D

vector<vector<int> >    v2(8, vector<int>(5));
Drab Dogfish

Jawaban yang mirip dengan “Inisialisasi vektor 2D”

Pertanyaan yang mirip dengan “Inisialisasi vektor 2D”

Lebih banyak jawaban terkait untuk “Inisialisasi vektor 2D” di C++

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya