Untitled
raw download clone
TEXT
views 15
,
size 1094 b
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <cstdlib>
#include <stdio.h>

using namespace std;

int main() {
    
    int N, i, j, **a;
    int memoryUsed = sizeof(N)+sizeof(i)+sizeof(j)+sizeof(a);
    cin>>N;
    a=new int *[N];
    for(i=0; i<N; i++){
        memoryUsed+=sizeof(a[i]);
        a[i]=new int [N];
        for(j=0; j<N; j++){
            a[i][j]=j*i;
            memoryUsed+=sizeof(a[i][j]);
        }
    }
    cout<<endl;
    for (i=0; i<N; i++){
        for(j=0; j<N; j++)
            cout<<a[i][j];
        cout<<endl;
        delete a[i];
    }
    delete []a;
    //El tamaƱo de la memoria es sin el sizeof del int "memoryUsed"
    cout<<endl<<"Memoria Usada: "<< memoryUsed <<endl;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.