online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <cstdlib> #include <time.h> #define N 5 using namespace std; void selectionSort(int arr[], int n) { for(int i=0; i<n-1; i++){ int min=i; for(int j=i+1; j<n; j++) if(arr[j] > arr[min]) min=j; if(min != i){ int temp = arr[min]; arr[min] = arr[i]; arr[i] = temp; } } } void bubbleSort(int arr[], int n) { for(int i=1; i<n; i++){ for(int j=0; j<n-i; j++){ if(arr[j] > arr[j+1]){ int temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } } } } int main() { srand(time(NULL)); int matriz[N][N]; int vector[N*N]; int i, j; /********************************************* ****************** PARTE 1 ****************** *********************************************/ // ASIGNANDO VALORES A LA MATRIZ for(i=0; i<N; i++){ for(j=0; j<N; j++){ matriz[i][j] = 1+rand()%100; } } // IMPRIMIENDO LA MATRIZ for(i=0; i<N; i++){ for(j=0; j<N; j++){ cout<<"["<<matriz[i][j]<<"] "; } cout<<endl; } cout<<"-------------------------"<<endl; /********************************************* ****************** PARTE 2 ****************** *********************************************/ //PASAMOS LA MATRIZ A UN VECTOR for(i=0; i<N; i++) for(j=0; j<N; j++) vector[i*N+j] = matriz[i][j]; //IMPRIMIENDO EL VECTOR B for (i=0; i<N*N; i++) cout<<vector[i]<<" "; cout<<endl<<"-------------------------"<<endl; //ORDENAMOS ASCENDENTEMENTE EL VECTOR CON "BUBBLE SORT" bubbleSort(vector, N*N); //IMPRIMIMOS EL VECTOR ORDENADO for (i=0; i<N*N; i++){ cout<<vector[i]<<" "; } cout<<endl<<"-------------------------"<<endl; //ORDENAMOS DESCENDIENTEMENTE EL VECTOR CON "SELECTION SORT" selectionSort(vector, N*N); //IMPRIMIMOS EL VECTOR ORDENADO for (i=0; i<N*N; i++){ cout<<vector[i]<<" "; } cout<<endl<<"-------------------------"<<endl; /********************************************* ****************** PARTE 3 ****************** *********************************************/ for(i=0; i<N; i++){ for(j=0; j<N; j++){ if(i==j) cout<<"["<<vector[j]<<"] "; else cout<<"[0] "; } cout<<endl; } return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue