online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include<iostream> #include<locale.h> #include<string.h> #include<conio.h> #include<stdlib.h> /* Crea un programa que guarde las nota y nombres de 10 alumnos en una matriz, y muestre las notas de mayor a menor junto con el nombre correcto del alumno. autor: Kevin Elián Valarezo Guamán date: 04/03/2024 */ int main(){ setlocale(LC_CTYPE, "Spanish"); int n = 0, cont = 0, cont2 = 0, aux = 0, min = 0; std::cout<<"Bienvenido al programa para ordenar notas de sus alumnos"<<std::endl<<"Realizado: Kevin Elián Valarezo Guamán"<<std::endl; char nombres[10][20]; int notas[2][5] = {{0, 0, 0, 0, 0},{0, 0, 0, 0, 0}}; int nots[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; for(int i = 0; i<10; i++){ std::cout<<"Alumno N°"<<i+1<<": "; std::cin.getline(nombres[i], 20, '\n'); } std::cout<<std::endl<<"Ingreso de notas\n"; for(int i = 0; i<2; i++){ for(int j = 0; j<5; j++){ std::cout<<nombres[cont]; std::cout<<": "; std::cin>>notas[i][j]; nots[cont2++] = notas[i][j]; cont++; if(notas[i][j]<0 || notas[i][j]>10){ std::cout<<"\nNo se permite el ingreso de esta nota"; j--; cont--; cont2--; std::cout<<"\n"; } } std::cout<<"\n"; } std::cout<<std::endl<<"Alumnos ingresados: ["; for(int i = 0; i<=9; i++){ if(i<9) std::cout<<nombres[i]<<", "; else std::cout<<nombres[i]; } std::cout<<"]"; std::cout<<std::endl<<"Notas ingresadas: ["; for(int i = 0; i<=1; i++){ for(int j = 0; j<=4; j++){ if(i==1 && j==4) std::cout<<notas[i][j]; else std::cout<<notas[i][j]<<", "; } } std::cout<<"]"; char aux2[20] = ""; char orden[20] = ""; for(int i = 0; i<10; i++){ strcpy(orden, nombres[i]); aux = nots[i]; int pos = i; while((nots[pos-1]<aux) && pos > 0){ nots[pos] = nots[pos - 1]; strcpy(nombres[pos], nombres[pos-1]); pos--; } nots[pos] = aux; strcpy(nombres[pos], orden); } cont2 = 0, cont = 0; for(int i = 0; i<2; i++){ for(int j = 0; j<5; j++){ notas[i][j] = nots[cont2++]; } } std::cout<<std::endl<<"Notas ordenadas:\n"; for(int i = 0; i<2; i++){ for(int j = 0; j<5; j++){ std::cout<<nombres[cont]; std::cout<<": "<<notas[i][j]; cont++; std::cout<<"\n"; } } getch(); }

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