THE INTRODUCTION OF 2 DIMENSIONAL ARRAYS IN C + +

Array is a type of structured data that is useful to store large amounts of data are the same type. Parts that make up the array called array elements, each element can be accessed separately through the array index. Array indices generally start at 0 and some are starting from the number instead of 0. Accessing the array is usually made by using a loop (looping). Two-dimensional array is an array of different types. Two-dimensional arrays are often used to represent tables and matrices in programming.

Example program 2 Dimensional Array

# Include <cstdlib>
# Include <iostream>

using namespace std;
class matrix {
public:
    friend istream & operator>> (istream &, matrix &);
    friend ostream & operator <<(ostream &, matrix &);
    masuk_data void ();
    matrix ();
  
private:
    int x [10] [10], n, m;};
    
matrix:: matrix () {
    court <<"\ t \ tSlamet Icelandic Al Hidayah" <<endl;
    court <<"\ t \ t 10018075" <<endl;
    court <<endl;
    court <<"PROGRAM MATRIX PRINT '<<endl;
    court <<endl;
    
}

istream & operator>> (istream & ins, matrix & a) {
     court <<"Enter the lot line:"; in>> a.n;
     court <<"Enter as many columns:"; in>> a.m;
     court <<endl;}

 void matrix:: masuk_data () {
     
for (int i = 0; i <n; i + +) {
       for (int j = 0; j <m, j + +) {
        court <<"Enter data to [" <<i +1 <<"]["<< j +1 <<"]:";
        
cin>> x [i] [j];
        }}
        }

ostream & operator <<(ostream & out, matrix & b) {
    court <<endl;
    
court <<"A lot of rows =" <<b.n <<endl;
    court <<"A lot of columns ="
​​<<b.n <<endl;
    
court <<endl;
    court <<"Matrix X =" <<endl;
    
for (int i = 0; i <b.n; i + +) {
    court <<"\ t";
       
for (int j = 0; j <b.m; j + +) {
         court <<b.x [i] [j] <<"\ t";
         } Court <<endl;
       
}
    }

int main (int argc, char * argv [])
{
 matrix x;
 cin>> x;
 x.masuk_data ();
 court <<x;
 court <<endl;
 
system ("PAUSE");
return EXIT_SUCCESS;
}
Output :


Well that's the program that I can make,,,,,!
If there are less jelass know any mistake, do not hesitate to leave a comment ataun advice. So that I can fix it later terimakasihh over his visit,,
Regards super ..

0 Response to " THE INTRODUCTION OF 2 DIMENSIONAL ARRAYS IN C + + "