fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6. int a,i;
  7. cin>>a; //the width of the array is variable
  8. int **p2darray;
  9. p2darray = new int*[2]; //the height is 2
  10. for (i = 0; i < 2; i++){
  11. p2darray[i] = new int[a];
  12. }
  13. i=0;
  14. while(i!=a){
  15. p2darray[0][i]=i; //filling some numbers in the array
  16. p2darray[1][i]=2*i;
  17. i++;
  18. }
  19. i=0;
  20. while(i!=a){
  21. cout<<p2darray[0][i]<<endl;
  22. cout<<p2darray[1][i]<<endl;
  23. i++;
  24. }
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 2816KB
stdin
3
stdout
0
0
1
2
2
4