Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #define MAX   5
  5.  
  6. typedef struct {
  7. char Nombre[30]; //* STRING *//
  8. char Apellido[30]; //* STRING *//
  9. int edad;
  10. char sexo;  //* F o M *//
  11. long dni;   //* DNI *//
  12. }Alumno;
  13. void buscar(char [],int, char[], int);
  14. void ingresar();
  15. void bedad();
  16. int busqueda();
  17. main(){
  18. char c; //* CARACTER *//
  19. int aux;
  20. int z,b=0;
  21. char s[30]; //* STRING *//
  22. Alumno alumnos[MAX];
  23. printf("Desea cargar un alumno? S/N\n");
  24. scanf("%c", &c);
  25. if (c=='S' || c=='s'){
  26. printf("Cuantos Alumnos desea cargar? (MAX 5)\n");
  27. scanf("%d", &z);
  28. while(z>MAX){
  29.         printf("ERROR: MAXIMO EXCEDIDO, INGRESE UN NUMERO VALIDO (MAX 5)\n");
  30. scanf("%d", &z);}
  31. ingresar(&alumnos,z);
  32.  
  33. }
  34. else {
  35.     printf("Usted dijo que no, adios.");
  36. exit(1);
  37. }
  38. printf("Que apellido deseas buscar?\n");
  39. scanf("%s", s);
  40. aux = busqueda(alumnos, s, b,z);
  41. if (aux!=0)
  42. printf("El apellido %s se repitio %d veces\n",s,aux);
  43. else
  44. printf("El apellido %s no se encontro\n",s,aux);
  45.  
  46. printf("Las personas que tengan 23 a%cos apareceran aqui\n",164);
  47. bedad(alumnos,b,z);
  48.     }
  49.  
  50.  
  51. void ingresar(Alumno *alumnos, int z)
  52. {
  53.     int i;
  54.     for (i=0; i<z; i++){
  55.     printf("Alumno %d\n", i+1);
  56.     printf("Ingrese el nombre\n");
  57.     scanf("%s", &(alumnos[i].Nombre));
  58.     printf("Ingrese el Apellido\n");
  59.     scanf(" %s", &(alumnos[i].Apellido));
  60.     printf("Ingrese su edad\n");
  61.     scanf("%d", &(alumnos[i].edad));
  62.     printf("Sexo? F/M\n");
  63.     scanf(" %c", &(alumnos[i].sexo));
  64.     printf("Ingrese su numero de DNI\n");
  65.     scanf("%d", &(alumnos[i].dni));
  66.     system("cls");
  67.  
  68.     }
  69.     }
  70.     int busqueda(Alumno *alumnos, char s[], int b, int z){
  71.         if(b>=z){
  72.             return 0;
  73.         }
  74.         else {
  75.             if(strcmp(alumnos[b].Apellido,s) == 0){
  76.  
  77.                    return 1 + busqueda(alumnos,s,b+1,z);
  78.             }
  79.             else {
  80.                 return 0 + busqueda(alumnos,s,b+1,z);
  81.             }
  82.         }}
  83. void bedad(Alumno *alumnos,int b, int z){
  84. if(b>=z){
  85.             return ;
  86.         }
  87.         else {
  88.             if((alumnos[b].edad) == 23){
  89. printf("*****************************\n");
  90. printf("%s \n",(alumnos[b].Nombre));
  91. printf("%s \n",(alumnos[b].Apellido));
  92. printf("%d \n",(alumnos[b].edad));
  93. printf("%c \n",(alumnos[b].sexo));
  94. printf("%d \n",(alumnos[b].dni));
  95. bedad(alumnos,b+1,z);
  96.                 }else{
  97.                 return bedad(alumnos,b+1,z);}
  98.             }
  99.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement