#include<stdio.h>
#define MTLE 41
#define MAU 41
#define MLST 5
struct book
{
char title[MTLE];
char author[MAU];
float value;
};
main()
{
struct book library[MLST];
int index,count=0;
printf("Please input the book's title:\n");
while(count<MLST&&gets(library[count].title)!=NULL&&library[count].title[0]!='\0')
{
printf("Please input the book's author:\n");
gets(library[count].author);
printf("Please input the book's value:\n");
scanf("%f",&library[count++].value);
while(getchar()!='\n')
continue;
if(count<MLST)
printf("please input the next book's title\n");
}
if(count>0)
for(index=0;index<count;index++)
printf("%s by %s,it's value is %.2f\n",library[index].title,library[index].author,library[index].value);
else
printf("No book!!\n");
}
#define MTLE 41
#define MAU 41
#define MLST 5
struct book
{
char title[MTLE];
char author[MAU];
float value;
};
main()
{
struct book library[MLST];
int index,count=0;
printf("Please input the book's title:\n");
while(count<MLST&&gets(library[count].title)!=NULL&&library[count].title[0]!='\0')
{
printf("Please input the book's author:\n");
gets(library[count].author);
printf("Please input the book's value:\n");
scanf("%f",&library[count++].value);
while(getchar()!='\n')
continue;
if(count<MLST)
printf("please input the next book's title\n");
}
if(count>0)
for(index=0;index<count;index++)
printf("%s by %s,it's value is %.2f\n",library[index].title,library[index].author,library[index].value);
else
printf("No book!!\n");
}