Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define MAX 5
- typedef struct {
- char Nombre[30]; //* STRING *//
- char Apellido[30]; //* STRING *//
- int edad;
- char sexo; //* F o M *//
- long dni; //* DNI *//
- }Alumno;
- void buscar(char [],int, char[], int);
- void ingresar();
- void bedad();
- int busqueda();
- main(){
- char c; //* CARACTER *//
- int aux;
- int z,b=0;
- char s[30]; //* STRING *//
- Alumno alumnos[MAX];
- printf("Desea cargar un alumno? S/N\n");
- scanf("%c", &c);
- if (c=='S' || c=='s'){
- printf("Cuantos Alumnos desea cargar? (MAX 5)\n");
- scanf("%d", &z);
- while(z>MAX){
- printf("ERROR: MAXIMO EXCEDIDO, INGRESE UN NUMERO VALIDO (MAX 5)\n");
- scanf("%d", &z);}
- ingresar(&alumnos,z);
- }
- else {
- printf("Usted dijo que no, adios.");
- exit(1);
- }
- printf("Que apellido deseas buscar?\n");
- scanf("%s", s);
- aux = busqueda(alumnos, s, b,z);
- if (aux!=0)
- printf("El apellido %s se repitio %d veces\n",s,aux);
- else
- printf("El apellido %s no se encontro\n",s,aux);
- printf("Las personas que tengan 23 a%cos apareceran aqui\n",164);
- bedad(alumnos,b,z);
- }
- void ingresar(Alumno *alumnos, int z)
- {
- int i;
- for (i=0; i<z; i++){
- printf("Alumno %d\n", i+1);
- printf("Ingrese el nombre\n");
- scanf("%s", &(alumnos[i].Nombre));
- printf("Ingrese el Apellido\n");
- scanf(" %s", &(alumnos[i].Apellido));
- printf("Ingrese su edad\n");
- scanf("%d", &(alumnos[i].edad));
- printf("Sexo? F/M\n");
- scanf(" %c", &(alumnos[i].sexo));
- printf("Ingrese su numero de DNI\n");
- scanf("%d", &(alumnos[i].dni));
- system("cls");
- }
- }
- int busqueda(Alumno *alumnos, char s[], int b, int z){
- if(b>=z){
- return 0;
- }
- else {
- if(strcmp(alumnos[b].Apellido,s) == 0){
- return 1 + busqueda(alumnos,s,b+1,z);
- }
- else {
- return 0 + busqueda(alumnos,s,b+1,z);
- }
- }}
- void bedad(Alumno *alumnos,int b, int z){
- if(b>=z){
- return ;
- }
- else {
- if((alumnos[b].edad) == 23){
- printf("*****************************\n");
- printf("%s \n",(alumnos[b].Nombre));
- printf("%s \n",(alumnos[b].Apellido));
- printf("%d \n",(alumnos[b].edad));
- printf("%c \n",(alumnos[b].sexo));
- printf("%d \n",(alumnos[b].dni));
- bedad(alumnos,b+1,z);
- }else{
- return bedad(alumnos,b+1,z);}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement