Created
November 30, 2017 14:14
-
-
Save Bojne/490037d1789fe1aea64354d6a978d086 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int* create2DArray(int rows,int columus){ | |
int *int_p; | |
int_p = new int[rows*columus]; | |
return int_p; | |
} | |
void set(int *arr,int rows,int columus,int desired_row,int desired_columu,int val){ | |
if((desired_row>=rows && desired_row<0) || (desired_columu>=columus && desired_columu<0)){ | |
cout<<"not exist"; | |
}else{ | |
arr[(desired_row)*columus+desired_columu]=val; | |
} | |
} | |
int get(int *arr,int rows,int columus,int desired_row,int desired_columu){ | |
if((desired_row>=rows && desired_row<0) || (desired_columu>=columus && desired_columu<0)){ | |
cout<<"not exist"; | |
}else{ | |
return arr[(desired_row)*columus+desired_columu]; | |
} | |
} | |
int main(){ | |
int *int_p,rows,columus,drow,dcolumu,val; | |
cin>>rows>>columus; | |
int_p = create2DArray(rows,columus); | |
cin>>drow>>dcolumu>>val; | |
set(int_p,rows,columus,drow,dcolumu,val); | |
cin>>drow>>dcolumu; | |
cout<<get(int_p,rows,columus,drow,dcolumu); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment