1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | // ÀϺΠ±â´É¸¸ ±¸ÇöµÇ¾î ÀÖ½À´Ï´Ù. #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; } | cs |