mirror of
https://github.com/c0de-archive/hacktoberfest-2018.git
synced 2024-12-22 05:12:40 +00:00
dynamic 2d array
code in c++ for a dynamic 2-dimensional array
This commit is contained in:
parent
3f1d1da695
commit
ff6b80af9a
26
code/dynamic_2d_array.cpp
Normal file
26
code/dynamic_2d_array.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include<vector>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int m;
|
||||||
|
cin>>m;
|
||||||
|
int *arr = new int[m*m];
|
||||||
|
for(int i=0;i<m;i++)
|
||||||
|
{
|
||||||
|
for(int j=0;j<m;j++)
|
||||||
|
{
|
||||||
|
cin>>arr[i*m+j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i=0;i<m;i++)
|
||||||
|
{
|
||||||
|
cout<<endl;
|
||||||
|
for(int j=0;j<m;j++)
|
||||||
|
{
|
||||||
|
cout<<arr[i*m+j]<<"\t";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user