elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Los 10 CVE más críticos (peligrosos) de 2020


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  agenda en c... problema con mostrar contactos y buscar contacto en especifico
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: agenda en c... problema con mostrar contactos y buscar contacto en especifico  (Leído 6,208 veces)
attackers

Desconectado Desconectado

Mensajes: 38


Ver Perfil
agenda en c... problema con mostrar contactos y buscar contacto en especifico
« en: 18 Noviembre 2011, 22:39 pm »

amigos tneog un problema con este codigo que despues que quiero mostrar los contactos de mi agenda me sale error

tambien quiero agregarle que busque un contacto en especifico
Código
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include <stdlib.h>
  4. #define p printf
  5. #define s scanf
  6.  
  7. struct contacto{
  8.       char nombre[40];
  9.       long telefono;
  10.       char equipo;
  11.       };
  12.     typedef struct contacto tipo_contacto;
  13.  
  14. int contador;
  15. int numerodeamigos;
  16.  
  17.  
  18.  
  19.  
  20. void main()
  21. {
  22. tipo_contacto c1;
  23. int numero;
  24. int i;
  25.  
  26.  
  27. do
  28. {
  29. p("\n\tPOR FAVOR ELIJA UNA DE LAS SIGUIENTES OPCIONES\n\n\n\n");
  30. p("\t1.AGREGAR CONTACTO\n");
  31. p("\n\t2.MOSTRAR CONTACTOS DE LA AGENDA \n\n");
  32.  
  33. scanf("%i",&numero);
  34. switch(numero)  
  35. {
  36.  
  37.                case 1:{
  38. system ("cls");
  39. printf("cuantos amigos quiere agregar: ");
  40. scanf("%d",&numerodeamigos);
  41. system("cls");
  42.  
  43.                            for (contador=0; contador<numerodeamigos; contador++)
  44.                             {
  45.  
  46.               printf("ingrese el nombre: ");
  47. fflush(stdin);
  48. gets(c1.nombre);
  49.               printf("diga su equipo: ");
  50. fflush(stdin);
  51. scanf("%c",&c1.equipo);
  52.  
  53.              printf("Ingrese el telefono: ");
  54. fflush(stdin);
  55. scanf("%d",&c1.telefono);
  56.  
  57. system("cls");
  58.          printf("\n");
  59. }
  60.  
  61. }
  62. break;
  63.  
  64.  
  65.  
  66. case 2:
  67.    {
  68. system ("cls");
  69.  
  70.  
  71.                        for (i=0; i<numerodeamigos; i++)
  72.   /***abre el for */ {
  73.    printf("El nombre es: %s, \n", c1.nombre);
  74.    printf ("el equipo es: %s \n",c1.equipo);
  75.    printf ("el telefono: %d  \n",c1.telefono);
  76.    system("pause");
  77.    } /**cierra el for**/
  78.  
  79.  
  80.    } /**cierra el case*/
  81.  
  82.    break;
  83.    } /***cierra el do***/
  84.    }/*** cierra el main **/
  85.  
  86.    while(numero<7);
  87.  
  88.          return 0;
  89.     }
  90.  
  91.  


En línea

s00rk

Desconectado Desconectado

Mensajes: 195



Ver Perfil
Re: agenda en c... problema con mostrar contactos y buscar contacto en especifico
« Respuesta #1 en: 20 Noviembre 2011, 01:04 am »

No sera porque tienes un solo dato y no un arreglo o puntero de ese tipo?

tipo_contacto c1; deberia ser
tipo_contacto c1[100];

o eso creo no recuerdo bien si tambien podria ser
tipo_contacto *c1;

Saludos & suerte n_n, ahorita no puedo checar lo demas por eso nomas puse eso ejje


En línea

Ferno


Desconectado Desconectado

Mensajes: 375


Ver Perfil
Re: agenda en c... problema con mostrar contactos y buscar contacto en especifico
« Respuesta #2 en: 20 Noviembre 2011, 02:40 am »

No se que error es el que te sale.
Pero el algoritmo no está bien, y también deberías pasarte por este hilo y leer un poco: http://foro.elhacker.net/programacion_cc/lo_que_no_hay_que_hacer_en_cc_nivel_basico-t277729.0.html

Lo que estás haciendo en tu algoritmo es pisar cada dato que estás pidiendo en el for. Fijate que estás escribiendo los nuevos datos que le pides al usuario sobre los que anteriormente guardaste!!
En línea

attackers

Desconectado Desconectado

Mensajes: 38


Ver Perfil
Re: agenda en c... problema con mostrar contactos y buscar contacto en especifico
« Respuesta #3 en: 20 Noviembre 2011, 04:21 am »

amigos ya solucione ahora le quiero hacer otras funcion  por ejemplo en los equipo quiero ponerle que agregue 2 equipo

CARAQUISTA Y MAGALLANES

entonce quiero que si piso 3 me muestre los contactos CARAQUISTAS y si PISO 4 que muestre los contactos MAGALLANEROS


Aqui les dejo el codigo

Código
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include <stdlib.h>
  4. #define p printf
  5. #define s scanf
  6.  
  7. struct contacto{
  8.       char equipo[40];
  9.       char nombre[40];
  10.       int telefono;
  11.       };
  12.     typedef struct contacto tipo_contacto;
  13.  
  14. int numero; /** el numero del menu de opciones*/
  15. int numerodeamigos;  /** el numero de amigos que quiero agregar a la agenda */
  16. int contadorAGREGAR;  /** el contador del for agregar*/
  17. int contadorELIMINAR;  /** el contador del for de eliminar */
  18.  
  19.  
  20. void main(void){
  21.  
  22.  
  23.  
  24. tipo_contacto c1[80];
  25. do
  26. {
  27. p("\n\tPOR FAVOR ELIJA UNA DE LAS SIGUIENTES OPCIONES\n\n\n\n");
  28. p("\t1.AGREGAR CONTACTO\n");
  29. p("\n\t2.MOSTRAR TODOS LOS CONTACTOS DE TU AGENDA \n\n");
  30. p("\t3.MOSTRAR LOS CONTACTOS MAGALLANEROS\n");
  31. p("\t4.MOSTRAR LOS CONTACTOS CARAQUISTA\n");
  32. scanf("%i",&numero);
  33. switch(numero)
  34.  
  35. {
  36. case 1:{
  37. system ("cls");
  38. printf("cuantos amigos quiere agregar: ");
  39. scanf("%i",&numerodeamigos);
  40.  
  41.  
  42.                            for (contadorAGREGAR=0; contadorAGREGAR<numerodeamigos; contadorAGREGAR++)
  43.                             {
  44.                             system("cls");
  45.  
  46.  
  47.               printf("ingrese el nombre: ");
  48.               fflush(stdin);
  49.             gets(c1[contadorAGREGAR].nombre);
  50.  
  51.  
  52. printf("Diga el equipo de su amigo: MAGALLANERO O CARAQUISTA\n");
  53. fflush(stdin);
  54.  gets(c1[contadorAGREGAR].equipo);
  55.  
  56.  
  57.              printf("Ingrese el telefono: ");
  58.                fflush(stdin);
  59.              scanf("%d",&c1[contadorAGREGAR].telefono);
  60.  
  61.              system("cls");
  62.          printf("\n");
  63. }
  64.  
  65. }
  66. break;
  67.  
  68.  
  69.  
  70. case 2:
  71.    {
  72. system ("cls");
  73.  
  74.                        for (contadorELIMINAR=0; contadorELIMINAR<numerodeamigos; contadorELIMINAR++)
  75.   /***abre el for */ {
  76.    printf("\nEl nombre es: %s \n", &c1[contadorELIMINAR].nombre);
  77.    printf ("el equipo es: %s \n",&c1[contadorELIMINAR].equipo);
  78.    printf ("el telefono: %d  \n",c1[contadorELIMINAR].telefono);
  79.  
  80.    } /**cierra el for**/
  81.  
  82.    system("pause");
  83.    } /**cierra el case*/
  84.  
  85.    break;
  86.  
  87.  
  88.  
  89.  
  90.    case 3:
  91.         {
  92.  
  93.         }
  94.  
  95.        break;
  96.  
  97.  
  98.  
  99.    } /***cierra el do***/
  100.    }/*** cierra el main **/
  101.  
  102.    while(numero<7);
  103.  
  104.          return 0;
  105.     }
  106.  
En línea

s00rk

Desconectado Desconectado

Mensajes: 195



Ver Perfil
Re: agenda en c... problema con mostrar contactos y buscar contacto en especifico
« Respuesta #4 en: 20 Noviembre 2011, 19:42 pm »

Porque simplemente no recorrer todo el arreglo de c1 y cuando el contacto sea CARAQUISTA lo muestre e igual con el otro ejemplo
Código
  1. for(in x = 0; x < numerodeamigos; x++)
  2. {
  3.    if(strcmp(c1[x].equipo,"caraquista") == 0)
  4.    {
  5.        //Imprimir datos
  6.    }
  7. }
e igual con el otro.

P.D. Tu codigo es un tanto ineficiente porque si pones que deceas agregar 4 usuarios, y luego deceas agregar otros 4 usuarios, estos no se agregaran sino reemplazaran a los anteriores y el chiste es que agregue a nuevos sin remover los que ya estan.
En línea

attackers

Desconectado Desconectado

Mensajes: 38


Ver Perfil
Re: agenda en c... problema con mostrar contactos y buscar contacto en especifico
« Respuesta #5 en: 21 Noviembre 2011, 04:03 am »


P.D. Tu codigo es un tanto ineficiente porque si pones que deceas agregar 4 usuarios, y luego deceas agregar otros 4 usuarios, estos no se agregaran sino reemplazaran a los anteriores y el chiste es que agregue a nuevos sin remover los que ya estan.


amigo y como mejoraria esa parte ??? aqui te dejo ya el codigo algo corregido


Código
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include <stdlib.h>
  4. #define p printf
  5. #define s scanf
  6. #include <string.h>
  7.  
  8. struct contacto{
  9.       char equipo[40];
  10.       char nombre[40];
  11.       int telefono;
  12.       };
  13.     typedef struct contacto tipo_contacto;
  14.  
  15. int numero; /** el numero del menu de opciones*/
  16. int numerodeamigos;  /** el numero de amigos que quiero agregar a la agenda */
  17. int contadorAGREGAR;  /** el contador del for agregar*/
  18. int contadorELIMINAR;  /** el contador del for de eliminar */
  19.  
  20.  
  21. int main(void)
  22. {
  23.  
  24. tipo_contacto c1[80];
  25. do
  26. {
  27. p("\n\tPOR FAVOR ELIJA UNA DE LAS SIGUIENTES OPCIONES\n\n\n\n");
  28. p("\t1.AGREGAR CONTACTO\n");
  29. p("\n\t2.MOSTRAR TODOS LOS CONTACTOS DE TU AGENDA \n\n");
  30. p("\t3.MOSTRAR LOS CONTACTOS MAGALLANEROS\n");
  31. p("\t4.MOSTRAR LOS CONTACTOS CARAQUISTA\n");
  32. scanf("%i",&numero);
  33. switch(numero)
  34.  
  35. {
  36. case 1:{
  37. system ("cls");
  38. printf("cuantos amigos quiere agregar: ");
  39. scanf("%i",&numerodeamigos);
  40.  
  41.  
  42.                            for (contadorAGREGAR=0; contadorAGREGAR<numerodeamigos; contadorAGREGAR++)
  43.                             {
  44.                             system("cls");
  45.  
  46.  
  47.               printf("ingrese el nombre: ");
  48.               fflush(stdin);
  49.             gets(c1[contadorAGREGAR].nombre);
  50.  
  51.  
  52. printf("Diga el equipo de su amigo: MAGALLANERO O CARAQUISTA\n");
  53. fflush(stdin);
  54.  gets(c1[contadorAGREGAR].equipo);
  55.  
  56.  
  57.              printf("Ingrese el telefono: ");
  58.                fflush(stdin);
  59.              scanf("%d",&c1[contadorAGREGAR].telefono);
  60.  
  61.              system("cls");
  62.          printf("\n");
  63. }
  64.  
  65. }
  66. break;
  67.  
  68.  
  69.  
  70. case 2:
  71.    {
  72. system ("cls");
  73.  
  74.                        for (contadorELIMINAR=0; contadorELIMINAR<numerodeamigos; contadorELIMINAR++)
  75.   /***abre el for */ {
  76.    printf("\nEl nombre es: %s \n", &c1[contadorELIMINAR].nombre);
  77.    printf ("el equipo es: %s \n",&c1[contadorELIMINAR].equipo);
  78.    printf ("el telefono: %d  \n",c1[contadorELIMINAR].telefono);
  79.  
  80.    } /**cierra el for**/
  81.  
  82.    system("pause");
  83.    } /**cierra el case*/
  84.  
  85.    break;
  86.  
  87. case 3:
  88.      {
  89.          for(int x = 0; x < numerodeamigos; x++)
  90.          {
  91.    if(strcmp(c1[x].equipo,"caraquista") == 0)
  92.    {
  93.        printf("los contactos caraquista son");                                
  94.    printf("\nEl nombre es: %s \n", &c1[x].nombre);
  95.    printf ("el telefono: %d  \n",c1[x].telefono);
  96.    }
  97.    }
  98.    }
  99. break;
  100.  
  101.  case 4:
  102.                          {
  103.  for(int y = 0; y < numerodeamigos; y++)
  104.          {
  105. if(strcmp(c1[y].equipo,"magallanero") == 0)
  106.    {
  107.        printf("los contactos caraquista son");                                
  108.    printf("\nEl nombre es: %s \n", &c1[y].nombre);
  109.    printf ("el telefono: %d  \n",c1[y].telefono);
  110.    }
  111.    }
  112.   }/**cierra el caso 4*/
  113.    } /***cierra el do***/
  114.    }/*** cierra el main **/
  115.  
  116.    while(numero<7);
  117.  
  118.     }
  119.  
En línea

attackers

Desconectado Desconectado

Mensajes: 38


Ver Perfil
Re: agenda en c... problema con mostrar contactos y buscar contacto en especifico
« Respuesta #6 en: 21 Noviembre 2011, 05:51 am »

amigos aqui les dejo el codigo con otras cositas mas o con otras dudas
la duda la tengo cuando quiero eliminar un contacto en espesifico como tendria que ser ?????

 
Código
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include <stdlib.h>
  4. #define p printf
  5. #define s scanf
  6. #include <string.h>
  7.  
  8. struct contacto{
  9.       char equipo[40];
  10.       char nombre[40];
  11.       int telefono;
  12.       };
  13.     typedef struct contacto tipo_contacto;
  14. int cont=0;
  15. int numero; /** el numero del menu de opciones*/
  16. int numerodeamigos;  /** el numero de amigos que quiero agregar a la agenda */
  17. int contadorAGREGAR;  /** el contador del for agregar*/
  18. int contadorELIMINAR;  /** el contador del for de eliminar */
  19.  
  20.  
  21. int main(void)
  22. {
  23.  
  24. tipo_contacto c1[80];
  25.  
  26. /*******************************************/
  27. /*******************************************/
  28. /************ MENU DE OPCIONES **************/
  29. /*******************************************/
  30. /*******************************************/
  31.  
  32. do
  33. {
  34. p("\n\tPOR FAVOR ELIJA UNA DE LAS SIGUIENTES OPCIONES\n\n\n\n");
  35. p("\t1.AGREGAR CONTACTO\n");
  36. p("\n\t2.MOSTRAR TODOS LOS CONTACTOS DE TU AGENDA \n\n");
  37. p("\t3.MOSTRAR LOS CONTACTOS CARAQUISTA\n");
  38. p("\t4.MOSTRAR LOS CONTACTOS MAGALLANEROS\n");
  39. p("\t5.BUSCAR CONTACTO\n");
  40. p("\t6.ELIMINAR CONTACTO\n");
  41. scanf("%i",&numero);
  42. switch(numero)
  43. {
  44.  
  45. /*******************************************/
  46. /*******************************************/
  47. /************ AGREGA LOS CONTACTOS **************/
  48. /*******************************************/
  49. /*******************************************/
  50. case 1:{
  51. system ("cls");
  52. printf("cuantos amigos quiere agregar: ");
  53. scanf("%i",&numerodeamigos);
  54.  
  55.  
  56.                            for (contadorAGREGAR=0; contadorAGREGAR<numerodeamigos; contadorAGREGAR++)
  57.                             {
  58.                             system("cls");
  59.  
  60.  
  61.               printf("ingrese el nombre: ");
  62.               fflush(stdin);
  63.             gets(c1[contadorAGREGAR].nombre);
  64.  
  65.  
  66. printf("Diga el equipo de su amigo: caraquista o magallanero \n");
  67. fflush(stdin);
  68.  gets(c1[contadorAGREGAR].equipo);
  69.  
  70.  
  71.              printf("Ingrese el telefono: ");
  72.                fflush(stdin);
  73.              scanf("%d",&c1[contadorAGREGAR].telefono);
  74.  
  75.              system("cls");
  76.          printf("\n");
  77. }
  78.  
  79. }
  80. break;
  81.  
  82. /*******************************************/
  83. /*******************************************/
  84. /*** MUESTRA LOS CONTACTO DE LA AGENDA *****/
  85. /*******************************************/
  86. /*******************************************/
  87.  
  88. case 2:
  89.    {
  90. system ("cls");
  91.  
  92.                        for (contadorELIMINAR=0; contadorELIMINAR<numerodeamigos; contadorELIMINAR++)
  93.   /***abre el for */ {
  94.    printf("\nEl nombre es: %s \n", &c1[contadorELIMINAR].nombre);
  95.    printf ("el equipo es: %s \n",&c1[contadorELIMINAR].equipo);
  96.    printf ("el telefono: %d  \n",c1[contadorELIMINAR].telefono);
  97.  
  98.    } /**cierra el for**/
  99.  
  100.    system("pause");
  101.    } /**cierra el case*/
  102.  
  103.    break;
  104. /*******************************************/
  105. /*******************************************/
  106. /****** MUESTRA CONTACTOS CARAQUISTAS *******/
  107. /*******************************************/
  108. /*******************************************/
  109. case 3:
  110.      {
  111.          for(int x = 0; x < numerodeamigos; x++)
  112.          {
  113.    if(strcmp(c1[x].equipo,"caraquista") == 0)
  114.    {
  115.        printf("los contactos caraquista son");                                
  116.    printf("\nEl nombre es: %s \n", &c1[x].nombre);
  117.    printf ("el telefono: %d  \n",c1[x].telefono);
  118.    }
  119.    }
  120.    }
  121. break;
  122. /*******************************************/
  123. /*******************************************/
  124. /****** MUESTRA CONTACTOS MAGALLANERO *******/
  125. /*******************************************/
  126. /*******************************************/
  127.  case 4:
  128.                          {
  129.  for(int y = 0; y < numerodeamigos; y++)
  130.          {
  131. if(strcmp(c1[y].equipo,"magallanero") == 0)
  132.    {
  133.        printf("los contactos magallanero son");                                
  134.    printf("\nEl nombre es: %s \n", &c1[y].nombre);
  135.    printf ("el telefono: %d  \n",c1[y].telefono);
  136.  
  137.  
  138.    }
  139.    }
  140.  
  141.    break;
  142.  
  143.  
  144.    case 5:
  145.         /****/
  146.  
  147.       {
  148. char busca[40];
  149. system("cls");
  150.  
  151. fflush(stdin);
  152. printf("\nBuscar contacto\n Ingrese el nombre del contacto:");
  153. gets(busca);
  154.  
  155. for(int k=1;k<numerodeamigos;k++){
  156. if(strcmpi(busca,c1[k].nombre)==0){
  157. printf("\nNombre: %s\n", c1[k].nombre);
  158. printf("Telefono fijo: %d\n", c1[k].equipo);
  159.  
  160.  
  161. }
  162. }
  163.  
  164. }
  165.  
  166. /******/
  167.  
  168.  
  169.  case 6:    
  170.       {
  171.       char busca1[40];
  172. system("cls");
  173.  
  174. fflush(stdin);
  175. printf("\n eliminar contacto \n Ingrese el nombre del contacto:");
  176. gets(busca1);
  177.  
  178. for(int e=1;e<numerodeamigos;e++){
  179. if(strcmpi(busca1,c1[e].nombre)==0){
  180. printf("\nNombre: %s\n", c1[e].nombre);
  181. printf("Telefono: %d\n", c1[e].telefono);
  182. printf("Telefono: %d\n", c1[e].equipo);
  183. printf("ELIMINADO");
  184. c1[e].nombre==NULL;
  185.  
  186.       }  
  187.       }
  188.       }
  189.  
  190.   }/**cierra el caso 4*/
  191.    } /***cierra el do***/
  192.    }/*** cierra el main **/
  193.  
  194.    while(numero<7);
  195.  
  196.     }
  197.  
  198.  
  199.  
En línea

s00rk

Desconectado Desconectado

Mensajes: 195



Ver Perfil
Re: agenda en c... problema con mostrar contactos y buscar contacto en especifico
« Respuesta #7 en: 21 Noviembre 2011, 19:53 pm »

Bueno ahora que tuve tiempo decidi hacerlo a mi modo, y aqui te dejo a como yo lo haria, espero te sirva

Código
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <iostream.h>
  4. using namespace std;
  5.  
  6. struct contacto{
  7.       char equipo[40];
  8.       char nombre[40];
  9.       int telefono;
  10.       int ocupado;
  11.       };
  12. typedef struct contacto tipo_contacto;
  13.  
  14. int main()
  15. {
  16.    int cont;
  17.    int numero; /** el numero del menu de opciones*/
  18.    int numerodeamigos;  /** el numero de amigos que quiero agregar a la agenda */
  19.    bool hayespacio;
  20.    char busca[40];
  21.  
  22.    tipo_contacto c1[80];
  23.    for(int x = 0; x < 80; x++)
  24.    {
  25.            c1[x].ocupado = 0;
  26.    }
  27.  
  28.  
  29.    do
  30.    {
  31.                  cout << "\tPOR FAVOR ELIJA UNA DE LAS SIGUIENTES OPCIONES" << endl << endl;
  32.                  cout << "\t1.AGREGAR CONTACTO" << endl;
  33.                  cout << "\t2.MOSTRAR TODOS LOS CONTACTOS DE TU AGENDA" << endl;
  34.                  cout << "\t3.MOSTRAR LOS CONTACTOS CARAQUISTA" << endl;
  35.                  cout << "\t4.MOSTRAR LOS CONTACTOS MAGALLANEROS" << endl;
  36.                  cout << "\t5.BUSCAR CONTACTO" << endl;
  37.                  cout << "\t6.ELIMINAR CONTACTO" << endl;
  38.                  cout << "\t0.SALIR" << endl;
  39.                  cin >> numero;
  40.                  system ("cls");
  41.                  switch(numero)
  42.                  {
  43.  
  44.                      case 1:                          
  45.  
  46.  
  47.                           cout << "Cuantos amigos deceas agregar:" << endl;
  48.                           cin >> numerodeamigos;
  49.  
  50.                           hayespacio = false;
  51.                           for(int i = 0; i < numerodeamigos; i++)
  52.                           {
  53.                                   for (int x = 0; x < 80; x++)
  54.                                   {
  55.                                       if(c1[x].ocupado == 0)
  56.                                       {
  57.                                               system("cls");
  58.                                               cout << "Contacto Numero[" << (i+1) << "]" << endl;
  59.                                               cout << "Ingrese el nombre: " << endl;
  60.                                               cin >> c1[x].nombre;
  61.                                               cout << "Diga el equipo de su amigo: caraquista o magallanero" << endl;
  62.                                               cin >> c1[x].equipo;
  63.                                               cout << "Ingrese el telefono: " << endl;
  64.                                               cin >> c1[x].telefono;
  65.                                               c1[x].ocupado = 1;
  66.  
  67.                                               hayespacio = true;
  68.                                               break;
  69.                                       }                      
  70.                                   }
  71.                           }
  72.                           system("cls");
  73.                           if(!hayespacio)
  74.                           {
  75.                                 cout << "No hubo espacio en la agenda para agregar nuevos contactos" << endl;
  76.                           }else{
  77.                                 cout << "Usuarios agregados Correctamente" << endl;
  78.                           }
  79.                           break;
  80.  
  81.                      case 2:
  82.                           hayespacio = false;
  83.                           for(int x = 0; x < 80; x++)
  84.                           {
  85.                                   if(c1[x].ocupado == 1)
  86.                                   {
  87.                                                   cout << "Contacto #" << (x+1) << endl;
  88.                                                   cout << "Nombre: " << c1[x].nombre << endl;
  89.                                                   cout << "Equipo: " << c1[x].equipo << endl;
  90.                                                   cout << "Telefono: " << c1[x].telefono << endl << endl << endl;
  91.                                                   hayespacio = true;
  92.                                   }
  93.                           }
  94.                           if(!hayespacio)
  95.                                          cout << "No hay contactos en la agenda" << endl;
  96.                           break;
  97.  
  98.                      case 3:
  99.                           cout << "Caraquista" << endl << endl;
  100.                           for(int x = 0; x < 80; x++)
  101.                           {
  102.                                   if(strcmp(c1[x].equipo,"caraquista") == 0 && c1[x].ocupado == 1)
  103.                                   {
  104.                                           cout << "Nombre: " << c1[x].nombre << endl;
  105.                                           cout << "Telefono: " << c1[x].telefono << endl;
  106.                                   }
  107.                           }
  108.                           break;
  109.  
  110.                      case 4:
  111.                           cout << "Magallanero" << endl << endl;
  112.                           for(int x = 0; x < 80; x++)
  113.                           {
  114.                                   if(strcmp(c1[x].equipo,"magallanero") == 0 && c1[x].ocupado == 1)
  115.                                   {
  116.                                           cout << "Nombre: " << c1[x].nombre << endl;
  117.                                           cout << "Telefono: " << c1[x].telefono << endl;
  118.                                   }
  119.                           }
  120.                           break;
  121.                      case 5:
  122.                           cout << "Buscar contacto" << endl << "Ingrese el nombre del contacto:" << endl;
  123.                           cin >> busca;
  124.                           hayespacio = true;
  125.                           for(int x = 0; x < 80; x++)
  126.                           {
  127.                                   if(strcmp(c1[x].nombre, busca) == 0 && c1[x].ocupado == 1)
  128.                                   {
  129.                                                          cout << endl << "Nombre: " << c1[x].nombre << endl;
  130.                                                          cout << "Telefono: " << c1[x].telefono << endl;
  131.                                                          cout << "Equipo: " << c1[x].equipo << endl;    
  132.                                                          hayespacio = true;                                                      
  133.                                   }
  134.                           }
  135.                           if(!hayespacio)
  136.                               cout << "No se encontro al contacto" << endl;
  137.                           break;
  138.                      case 6:    
  139.                           cout << "Eliminar contacto" << endl << "Ingrese el nombre del contacto:" << endl;
  140.                           cin >> busca;
  141.                           hayespacio = false;
  142.                           for(int x = 0; x < 80; x++)
  143.                           {
  144.                                   if(strcmp(c1[x].nombre,busca) == 0 && c1[x].ocupado == 1)
  145.                                   {
  146.                                        c1[x].ocupado = 0;
  147.                                        cout << endl << "Usuario Eliminado" << endl;
  148.                                        hayespacio = true;  
  149.                                   }
  150.                           }
  151.                           if(!hayespacio)
  152.                               cout << "No se encontro al contacto" << endl;
  153.                           break;
  154.                      default:
  155.                              cout << "Eleccion elegida no existe" << endl;
  156.                              break;
  157.                  }
  158.                  getchar();getchar();
  159.                  system("cls");
  160.  
  161.    }while(numero != 0);
  162.    cin.get();cin.get();
  163.    return 0;
  164. }
  165.  
  166.  
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
mostrar contactos de una agenda por equipo
Programación C/C++
attackers 3 2,184 Último mensaje 24 Noviembre 2011, 22:20 pm
por satu
La aplicación Google Now ya no necesita Internet para mostrar la agenda de ...
Noticias
wolfbcn 0 1,055 Último mensaje 4 Mayo 2014, 21:38 pm
por wolfbcn
[BATCH] Buscar una palabra en especifico de un log.
Scripting
Vapirox 0 2,256 Último mensaje 21 Octubre 2016, 17:13 pm
por Vapirox
Cómo enviar un WhatsApp a alguien que no está en tu agenda de contactos
Noticias
wolfbcn 0 1,879 Último mensaje 25 Octubre 2017, 01:59 am
por wolfbcn
buscar un resultado especifico en una lista
Scripting
flony 3 3,628 Último mensaje 25 Septiembre 2022, 00:54 am
por flony
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines