#include <stdio.h>
#include <time.h>
#include <iostream.h>
using namespace std;
struct contacto{
char equipo[40];
char nombre[40];
int telefono;
int ocupado;
};
typedef struct contacto tipo_contacto;
int main()
{
int cont;
int numero; /** el numero del menu de opciones*/
int numerodeamigos; /** el numero de amigos que quiero agregar a la agenda */
bool hayespacio;
char busca[40];
tipo_contacto c1[80];
for(int x = 0; x < 80; x++)
{
c1[x].ocupado = 0;
}
do
{
cout << "\tPOR FAVOR ELIJA UNA DE LAS SIGUIENTES OPCIONES" << endl << endl;
cout << "\t1.AGREGAR CONTACTO" << endl;
cout << "\t2.MOSTRAR TODOS LOS CONTACTOS DE TU AGENDA" << endl;
cout << "\t3.MOSTRAR LOS CONTACTOS CARAQUISTA" << endl;
cout << "\t4.MOSTRAR LOS CONTACTOS MAGALLANEROS" << endl;
cout << "\t5.BUSCAR CONTACTO" << endl;
cout << "\t6.ELIMINAR CONTACTO" << endl;
cout << "\t0.SALIR" << endl;
cin >> numero;
switch(numero)
{
case 1:
cout << "Cuantos amigos deceas agregar:" << endl;
cin >> numerodeamigos;
hayespacio = false;
for(int i = 0; i < numerodeamigos; i++)
{
for (int x = 0; x < 80; x++)
{
if(c1[x].ocupado == 0)
{
cout << "Contacto Numero[" << (i+1) << "]" << endl;
cout << "Ingrese el nombre: " << endl;
cin >> c1[x].nombre;
cout << "Diga el equipo de su amigo: caraquista o magallanero" << endl;
cin >> c1[x].equipo;
cout << "Ingrese el telefono: " << endl;
cin >> c1[x].telefono;
c1[x].ocupado = 1;
hayespacio = true;
break;
}
}
}
if(!hayespacio)
{
cout << "No hubo espacio en la agenda para agregar nuevos contactos" << endl;
}else{
cout << "Usuarios agregados Correctamente" << endl;
}
break;
case 2:
hayespacio = false;
for(int x = 0; x < 80; x++)
{
if(c1[x].ocupado == 1)
{
cout << "Contacto #" << (x+1) << endl;
cout << "Nombre: " << c1[x].nombre << endl;
cout << "Equipo: " << c1[x].equipo << endl;
cout << "Telefono: " << c1[x].telefono << endl << endl << endl;
hayespacio = true;
}
}
if(!hayespacio)
cout << "No hay contactos en la agenda" << endl;
break;
case 3:
cout << "Caraquista" << endl << endl;
for(int x = 0; x < 80; x++)
{
if(strcmp(c1
[x
].
equipo,"caraquista") == 0 && c1
[x
].
ocupado == 1) {
cout << "Nombre: " << c1[x].nombre << endl;
cout << "Telefono: " << c1[x].telefono << endl;
}
}
break;
case 4:
cout << "Magallanero" << endl << endl;
for(int x = 0; x < 80; x++)
{
if(strcmp(c1
[x
].
equipo,"magallanero") == 0 && c1
[x
].
ocupado == 1) {
cout << "Nombre: " << c1[x].nombre << endl;
cout << "Telefono: " << c1[x].telefono << endl;
}
}
break;
case 5:
cout << "Buscar contacto" << endl << "Ingrese el nombre del contacto:" << endl;
cin >> busca;
hayespacio = true;
for(int x = 0; x < 80; x++)
{
if(strcmp(c1
[x
].
nombre, busca
) == 0 && c1
[x
].
ocupado == 1) {
cout << endl << "Nombre: " << c1[x].nombre << endl;
cout << "Telefono: " << c1[x].telefono << endl;
cout << "Equipo: " << c1[x].equipo << endl;
hayespacio = true;
}
}
if(!hayespacio)
cout << "No se encontro al contacto" << endl;
break;
case 6:
cout << "Eliminar contacto" << endl << "Ingrese el nombre del contacto:" << endl;
cin >> busca;
hayespacio = false;
for(int x = 0; x < 80; x++)
{
if(strcmp(c1
[x
].
nombre,busca
) == 0 && c1
[x
].
ocupado == 1) {
c1[x].ocupado = 0;
cout << endl << "Usuario Eliminado" << endl;
hayespacio = true;
}
}
if(!hayespacio)
cout << "No se encontro al contacto" << endl;
break;
default:
cout << "Eleccion elegida no existe" << endl;
break;
}
}while(numero != 0);
cin.get();cin.get();
return 0;
}