// ÀϺΠ±â´É¸¸ ±¸ÇöµÇ¾î ÀÖ½À´Ï´Ù.
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct book
{
int id;
char name[30];
char author[30];
};
struct book library[1000];
int main()
{
char name[30], author[30];
int select = 0;
int nbooks = 0;
while (select != 6)
{
int select;
printf("===========================================\n");
printf("1. µµ¼ ¹øÈ£·Î Ã¥ ã±â\n");
printf("2. ÀúÀÚ À̸§À¸·Î Ã¥ ã±â\n");
printf("3. Á¦¸ñÀ¸·Î Ã¥ ã±â\n");
printf("4. »õ·Î¿î Ã¥ Ãß°¡\n");
printf("5. µµ¼°üÀÌ ¼ÒÀåÇÑ µµ¼ÀÇ ¼ö Ç¥½Ã\n");
printf("6. Á¾·á\n");
printf("===========================================\n");
printf("¸Þ´º Áß¿¡¼ Çϳª¸¦ ¼±ÅÃÇϼ¼¿ä: \n");
scanf("%d", &select);
getchar();
switch (select)
{
case 4:
printf("Ã¥ À̸§ = ");
gets_s(library[nbooks].name, 30);
printf("ÀúÀÚ À̸§ = ");
gets_s(library[nbooks].author, 30);
library[nbooks].id = nbooks;
nbooks++;
break;
case 5:
for (int i = 0; i < nbooks; i++)
{
printf("Ã¥À̸§ = %s", library[i].name);
printf("ÀúÀÚ = %s", library[i].author);
}
printf("\n");
break;
case 2:
printf("ÀúÀÚ À̸§À» ÀÔ·ÂÇϽÿÀ : ");
scanf("%s", author);
for (int i = 0; i < nbooks; i++)
{
if (strcmp(author, library[i].author) == 0)
printf("%s %s \n", library[i].name, library[i].author);
}
break;
case 6:
exit(0);
}
}
return 0;
}