Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ fill two dimensional array

//this way you can fill your array row by row
for (int i = 0; i < row; i++){
	for (int j = 0; j < column; j++){
		cin >> x;
        array[i][j] = x;
	}
}

//	[ 1 2 3 ]
//	[ 4 5 6 ]
//	[ 7 8 9 ]

//this way you can fill your array column by column

for (int i = 0; i < column; i++){
	for (int j = 0; j < row; j++){
		cin >> x;
        array[i][j] = x;
	}
}

// [ 1 4 7 ]
// [ 2 5 8 ]
// [ 3 6 9 ]
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to make a vector in c++ 
Cpp :: C++ fibo 
Cpp :: prevent copy c++ 
Cpp :: oncomponentendoverlap ue4 c++ 
Cpp :: c++ sizeof 
Cpp :: constrain function in arduino 
Cpp :: C++ program to sizes of data types 
Cpp :: basic cpp 
Cpp :: how to traverse through vector pair 
Cpp :: set size of a vector c++ 
Cpp :: vector::at() || Finding element with given position using vector in C++ 
Cpp :: . Write a C++ program to calculate area of a Triangle 
Cpp :: minheap cpp stl 
Cpp :: C++ if...else...else if statement 
Cpp :: c++ insert hashmap 
Cpp :: initialize a vector with same values 
Cpp :: c++ define array with values 
Cpp :: cpp undefined reference to function 
Cpp :: use set to get duplicates in c++ 
Cpp :: c++ else if 
Cpp :: invert a binary tree 
Cpp :: c++ main function parameters 
Cpp :: c++ custom printf 
Cpp :: c++ add everything in a vector 
Cpp :: c++ read entire file into a variable 
Cpp :: c++ the hash function with 31 const 
Cpp :: how to increase the length of a string 
Cpp :: arithmetic progression c++ 
Cpp :: how to code a game in c++ 
Cpp :: string in int in cpp 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =