online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <algorithm> // para la funcion sort using namespace std; typedef struct Persona { string nombre; int Num_lista; int edad; int peso; }Estudiante; //declara la variable Estudiante /*La funcion compare (<) ordena en forma ascendente, reemplazar con (>) para orden descendente */ bool compare(Estudiante a, Estudiante b){ /** para usar otro atributo para el ordenamiento, remplace 'edad' con ese atributo por ej. (a.Num_lista < b.Num_lista) EL valor de retorno determina que estudiante aparecerá primero en el arreglo ordenado **/ if(a.edad < b.edad) return 1; else return 0; } int main() { int i, n; cout<<"Ingrese el Numero de Estudiantes :"; // determinar el tamaño del arreglo cin>> n; // Declara el Arrreglo de Estudiantes Estudiante ArregloEst[n]; cout<<"Ingrese el Nombre del Estudiante, Numero de Lista, edad, y peso \n\n"; for(i=0; i<n; i++){ cout<<"---------\n"; cin>>ArregloEst[i].nombre; cin>>ArregloEst[i].Num_lista; cin>>ArregloEst[i].edad; cin>>ArregloEst[i].peso; } sort(ArregloEst, ArregloEst+n, compare); /** Esta es la funcion de ordenamiento su primer y segundo parámetros indican el rango del arreglo que queremos que se ordene el tercer parámetro es la funcionn de comparación **/ cout<<"\n Esta es la lista ordenada de estudiantes :\n"; for(i=0; i<n; i++){ cout<<ArregloEst[i].nombre<<" "; cout<<ArregloEst[i].Num_lista<<" "; cout<<ArregloEst[i].edad<<" "; cout<<ArregloEst[i].peso<<endl; } }

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