Documentos de Académico
Documentos de Profesional
Documentos de Cultura
c**********
#include <stdio.h>
#include <stdlib.h>
#include "Libro.h"
**********Libro.h**********
typedef struct {
int Clave_del_libro;
char Titulo[30];
float Precio;
} Libro;
**********Libro.c**********
#include <stdio.h>
#include <stdlib.h>
#include "Libro.h"
printf("\n");
printf("Ingresa el nombre del autor\n");
fflush(stdin);
gets(libro->autor.Nombre);
fflush(stdin);
printf("\n");
printf("Ingresa el apellido del autor\n");
gets(libro->autor.Apellido);
fflush(stdin);
printf("\n\n\n");
}
}
**********Libro.h**********
typedef struct {
char Nombre [30];
char Apellido [30];
} Autor;
typedef struct {
int Clave_del_libro;
char Titulo[30];
float Precio;
Autor autor;
} Libro;
**********Libro.c**********
#include <stdio.h>
#include <stdlib.h>
#include "Libro.h"
printf("\n");
printf("Ingresa el nombre del autor\n");
fflush(stdin);
gets(libro->autor.Nombre);
fflush(stdin);
printf("\n");
printf("Ingresa el apellido del autor\n");
gets(libro->autor.Apellido);
fflush(stdin);
printf("\n\n\n");
}
}
**********Libro.h**********
typedef struct {
char Nombre [30];
char Apellido [30];
} Autor;
typedef struct {
int Clave_del_libro;
char Titulo[30];
float Precio;
Autor autor;
} Libro;
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define max 5
int main() {
/*Variables locales*/
int arreglo[max];
int indice;
pos= Buscar(dato,arreglo,indice);
if (pos !=-1)
ListarDato(arreglo,pos);
break;
case 5: /*Listar*/
Listar(arreglo, indice);
break;
case 6: /*Ordenar*/
break;
}
system("pause");
system("cls");
/*============================================*/
int Menu (char texto[], int n) {
int opcion;
do {
printf("%s ",texto);
scanf("%d", &opcion);
if (opcion < 1 || opcion > n)
printf("Error: opcion no valida...\n");
} while (opcion < 1 || opcion > n);
return opcion;
}
/*=================================================*/
printf("\n");
}
int Buscar(int dato, int arreglo[], int indice) {
int i;
for(i=0; i<=indice; i++){
if(dato==arreglo[i])
return i;
}
printf("No existe el dato %d en el arreglo\n", dato);
return -1;
}
/
*=========================================================
==*/