Ads by Smowtion

Anuncios

Anuncios

jueves, 17 de mayo de 2012

Código semana del 17-05-2012

Código visto esta semana

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct lista
{
   char nombre[100];
   char apellido[100];
   char rut[100];
   char f_nac[100];
   int edad;
}BD;

BD llenar(BD nuevo)
{
   printf("\nIngrese su nombre: ");
   gets(nuevo.nombre);
   printf("\nIngrese el Apellido: ");
   gets(nuevo.apellido);
   printf("\nIngrese Rut: ");
   gets(nuevo.rut);
   printf("\nIngrese fecha de Nacimiento: ");
   gets(nuevo.f_nac);
   printf("\nIngrese su edad: ");
   scanf("%d", &(nuevo.edad));
   getchar();            
   return nuevo;
}

void imprimir(BD nuevo)
{
   printf("\nSU NOMBRE ES: %s", nuevo.nombre);
   printf("\nSU APELLIDO ES: %s", nuevo.apellido);
   printf("\nSU RUT ES: %s", nuevo.rut);
   printf("\nSU FECHA DE NACIMIENTO ES: %s", nuevo.f_nac);
   printf("\nSU EDAD ES: %d", nuevo.edad);
}

void busqueda(BD lista[], char rut[], int x)
{
   int i;
   for(i=0;i<x;i++)
   {
      if(strcmp(lista[i].rut, rut)==0)
      {
         imprimir(lista[i]);
         break;
      }
   }
}


int main()
{
   BD dato[100];
   int n, c;
   char brut[100];
   system("Color 1f");
   printf("INGRESE CANTIDAD DE PERSONAS: ");
   scanf("%d", &n);
   getchar();
   for(c=0;c<n;c++)
   {
      dato[c]=llenar(dato[c]);
   }
   for(c=0;c<n;c++)
   {
      imprimir(dato[c]);                     
   }
   printf("\nINGRESE RUT A BUSCAR: ");
   gets(brut);
   busqueda(dato, brut, n);
   getchar();
   getchar();
   return 0;
}

No hay comentarios:

Publicar un comentario

Anuncios