Advertisement
attackers

attac

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