Search a two-dimension array : multi dimension array « Array « C++ Tutorial






#include <iostream> 
#include <cstdio> 
using namespace std; 
 
int main() 
{ 
  int i; 
  char str[80]; 
  char numbers[10][80] = { 
    "A", "322", 
    "B", "976", 
    "C", "037", 
    "D", "400", 
    "E", "873" 
  }; 
 
  cout << "Enter name (A): "; 
  cin >> str; 
 
  for(i=0; i < 10; i += 2)  
    if(!strcmp(str, numbers[i])) { 
      cout << "Number is " << numbers[i+1] << "\n"; 
      break; 
    } 
   
  if(i == 10) cout << "Not found.\n"; 
   
 
  return 0; 
}
Enter name (A): 1
Not found.








4.4.multi dimension array
4.4.1.Declare a two-dimension array
4.4.2.Initialize a two-dimension array
4.4.3.Creating A Multidimensional Array
4.4.4.Initializing multidimensional arrays
4.4.5.Search a two-dimension array
4.4.6.Use nested for loop to display the two dimesional array
4.4.7.Using pointer notation with a multidimensional array
4.4.8.Fill a two dimensional integer array element by element
4.4.9.how to define, pass, and walk through the different dimensions of an array