본문 바로가기
컴퓨터과학[1-2]/knou_C++

배열 포인터 활용

by boolean 2014. 9. 23.
728x90

#include "stdafx.h"

#include <iostream>

using namespace std;



void main(int argc, _TCHAR* argv[])

{

double iarr2[2][3] = { 10,20,30,40,50,60};


cout << "배열 포인터 활용 "  << endl << endl;

cout << "****************   iarr2[i][j] " <<endl;

for(int i = 0; i <2; i ++){  // iarr2[i][j]

for(int j = 0; j < 3; j ++){

cout << "iarr2["<<i<<"]["<<j<<"] : " ;

cout << iarr2[i][j] << "  ";

}

cout << endl;

}

cout <<endl << "***************   *(iarr2[i]+j) "<<endl;

for(int i = 0; i <2; i ++){  // *(iarr2[i] + j)

for(int j = 0; j < 3; j ++){

cout << "iarr2["<<i<<"]["<<j<<"] : " ;

cout << *(iarr2[i]+j) << "  ";

}

cout << endl;

}

cout <<endl << "****************   *(*(iarr2 +i) +j) "<< endl;

for(int i = 0; i <2; i ++){     // *(*(iarr2 +i) +j)

for(int j = 0; j < 3; j ++){

cout << "iarr2["<<i<<"]["<<j<<"] : " ;

cout << *(*(iarr2+i)+j) << "  ";

}

cout << endl;

}

       int  k = 0;

  cout << endl << "****************   *(*(iarr2 +i) +j)" << endl;

for(int i = 0; i <1; i ++){       // iarr2[0][6]

for(int j = 0; j < 6; j ++){

cout << "iarr2["<<i<<"]["<<j<<"] : " ;

cout << iarr2[i][j] << "   ";

k++;

if(k%3 == 0){

cout << endl;

}


}

}

        k = 0;

cout <<endl <<  "****************   iarr2[1][-3] " << endl;

for(int i = 1; i <2; i ++){        // iarr2[1][-3]

for(int j = -3; j < 3; j ++){

cout << "iarr2["<<i<<"]["<<j<<"] : " ;

cout << iarr2[i][j] << "  ";

k++;

if(k%3 == 0){

cout << endl;

}

}

}


}



댓글