Vous êtes sur la page 1sur 5

#include<stdio.

h>
#include<stdlib.h>
#include<iostream>

using namespace std;


int main (){
char nombre[3][50];
int edad[3];
int i,j;
int auxiliar[3];
int mayor;
int menor;
int opcion;
system("color 2e");
system("cls");

cout<<endl<<"\t//////////////////////////////////////////////////////////////////////";
cout<<endl<<"\t----------------------------------------------------------------------";
cout<<endl<<"\t Trabajo Colaborativo 3 ";
cout<<endl<<"\t Introduccion a la programacion
";
cout<<endl<<"\t----------------------------------------------------------------------";
cout<<endl<<"\t//////////////////////////////////////////////////////////////////////
"<<endl;
do{
cout<<"\n";
cout<<"-------------------MENU PRINCIPAL-----------------"<<endl;
cout<<"\n";
cout << "1.- Registar datos" << endl;
cout << "2.- listar datos" << endl;
cout << "3.- Ordenar datos por edad" << endl;
cout << "4.- Imprimir nombre de la persona de mayor edad" << endl;
cout << "5.- Imprimir nombre de la persona de menor edad" << endl;
cout << "6.- Salir" << endl;
cout<<"\n";
cout << endl;
cout<<"--------Elija la opcion deseada---------"<<endl<<endl;
cout<<"----------------------------------------"<<endl<<endl;
cin >> opcion;
switch(opcion)

{
case 1:
cout << "----------- REGISTRO DE DATOS-------" << endl;
cout<< " \n";

for(i = 0 ; i < 3 ; i++)


{
printf("ingrese el primer nombre y la edad\n");
scanf("%s",&nombre[i]);
cout<<"\n";
scanf("%d",&edad[i]);
cout<<"\n";
auxiliar[i] = edad[i];
cout<<"\n";

}
cout << "----------- HECHO POR-------" << endl;
cout<<"Andre Nathalia Quevedo Avellaneda"<<endl<<endl;
break;
case 2:

cout<<"\n";
cout << "---------------INFORMACION-------------" << endl;
cout<<"\n";

printf("%s %d ",nombre[1],edad[1]);printf("aos");
cout<<"\n";
printf("%s %d ",nombre[2],edad[2]);printf("aos");
cout<<"\n";
printf("%s %d ",nombre,auxiliar[3]);printf("aos");
cout<<"\n";
break;
case 3:
cout<<"\n";
cout << "-------- ORDENAR DATOS POR EDAD --------" << endl;
cout<<"\n";

for(i = 1 ; i < 3 ; i++){


for(j=0; j < 3-i ; j++){
if ( auxiliar[j] > auxiliar [j+1]){
mayor = auxiliar [j];
auxiliar[j] = auxiliar[j+1];
auxiliar[j+1] = mayor;
}
}
}

for(i = 0 ; i < 3 ; i++){


for (j = 0 ; j < 3 ; j++){
if(edad[j] == auxiliar[i]){
printf("%s edad %d ",nombre[j],edad[j]);printf("aos \n");
if(i == 0) menor = j;
else if(i == 2) mayor = j;
}
}

}
cout << "----------- HECHO POR-------" << endl;
cout<<"Manuel Jose Santos Palomino"<<endl<<endl;
break;
case 4:
cout<<"\n";
cout<<"-------- IMPRIMIR NOMBRE DE LA PERSONA DE MAYOR EDAD-------- :";
cout<<"\n";

printf("El mayor es %s \n",nombre[mayor]);


cout << "----------- HECHO POR-------" << endl;
cout<<"Yamid Pabon Pabon"<<endl<<endl;

break;

cout<<"Vuelva Pronto"<<endl<<endl;
cout<<"UNIVERSIDAD NACIONAL ABIERTA Y A DISTANCIA____UNAD"<<endl<<endl;
cout<<"Estudiantes que participaron:"<<endl;
cout<<"Grupo 301304_69"<<endl;
cout<<"Comentarios:"<<endl<<endl;
cout<<"1- las funciones son de vital importancia a la hora de resolver problemas
especificos de programacion, sobre todo en el manejo de datos utilizando arreglos, mtodos de
ordenacin y bsqueda."<<endl<<endl;

break;
}
}while(opcion != 6);

return 0;

Vous aimerez peut-être aussi