Search
 
SCRIPT & CODE EXAMPLE
 

CPP

fill two dimension array c++

//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 :: c++ converting centimeters to kilometers 
Cpp :: C++ Kelvin to Celsius 
Cpp :: what is difference between single inverted and double inverted in programming languages 
Cpp :: rapidjson write stringbuffer to file 
Cpp :: c++ fast 
Cpp :: C++ Third angle of a Triangle 
Cpp :: c++ nth substr 
Cpp :: c++ for loop 
Cpp :: c++ make constructor fails if bad argument 
Cpp :: C++ add value to exception message 
Cpp :: fast input and output c++ 
Cpp :: hi cpp 
Cpp :: temporary mobile number 
Cpp :: print 5 table in c++ 
Cpp :: c++ program to add two numbers using function 
Cpp :: xmake set exe name 
Cpp :: check if c++ is installed 
Cpp :: Vector2 c++ 
Cpp :: c++ triangle 
Cpp :: format c++ discord 
Cpp :: c++ area of triangle 
Cpp :: initializing 2d vector 
Cpp :: c++ mst kruskal 
Cpp :: g++ optimization flags 
Cpp :: qt disable resizing window 
Cpp :: delete map elements while iterating cpp 
Cpp :: sort stl 
Cpp :: iterate over map c++17 
Cpp :: how to make a list in c++ 
Cpp :: c++ function for checking if a sting is a number 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =