Search
 
SCRIPT & CODE EXAMPLE
 

CPP

fill two dimensional 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 :: long long int range c++ 
Cpp :: cpp gui 
Cpp :: cpp read from file 
Cpp :: text color c++ 
Cpp :: how to access a vector member by its index 
Cpp :: 1768. Merge Strings Alternately leetcode solution in c++ 
Cpp :: resharper fold if statement 
Cpp :: program to swap max and min in matrix 
Cpp :: how to reset linerenderer unity 
Cpp :: c++ map lookup 
Cpp :: how to format big numbers with commas in c++ 
Cpp :: struct node 
Cpp :: print elements of linked list 
Cpp :: c++ call by value 
Cpp :: c++ std map initializer list 
Cpp :: c++ generic pointer 
Cpp :: c++ print array of arrays with pointer 
Cpp :: __builtin_popcount 
Cpp :: c++ string to char* 
Cpp :: if not c++ 
Cpp :: 1. Two Sum 
Cpp :: binary to decimal 
Cpp :: cpp compiler online 
Cpp :: double plus overload 
Cpp :: array bubble sort c++ static 
Cpp :: how to bath without water 
Cpp :: Vaccine Dates codechef solution in c++ 
Cpp :: binary to int c++ bitset 
Cpp :: what is xor_eq c++ 
Cpp :: find substring after character 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =