소스한번 봐주세요..ㅜ
가온누리
#includestdio.h
#includestring.h
struct Book{
char title[100];
char author[100];
char publish[100];
int pages;
int price;
};
typedef struct Book MyBook;
void print(MyBook a){
printf(-------------책을 출력합니다------------\n);
printf(제목 : %s\n,a.title);
printf(저자 : %s\n,a.author);
printf(출판사 : %s\n,a.publish);
printf(페이지 : %d\n,a.pages);
printf(가격 : %d\n,a.price);
}
void pr(int index, struct Book *p){
printf(-------------%d번째 책을 출력합니다------------\n,index+1);
printf(제목 : %s\n,p-title);
printf(저자 : %s\n,p-author);
printf(출판사 : %s\n,p-publish);
printf(페이지 : %d\n,p-pages);
printf(가격 : %d\n,p-price);
}
void input(int index, struct Book *p){
printf(-- %d번째 책 입력합니다. --\n,index+1);
printf(제목 );
scanf(%s,p-title);
printf(저자 );
scanf(%s,p-author);
printf(출판사 );
scanf(%s,p-publish);
printf(페이지수 );
scanf(%d,&p-pages);
printf(가격 );
scanf(%d,&p-price);
}
void inputAll(int n, struct Book p[]){
int i;
for(i=0;in;i++){
input(i, &p[i]);
printf(\n);
}
}
void printAll(int n, struct Book p[]){
int i;
for(i=0;in;i++){
pr(i, &p[i]);
}
}
void find(char name[], struct Book p[],int n){
int i;
for(i = 0; in;i++){
if(strcmp(name,p[i].title) ==0){
printf(%s의 저자는 %s입니다\n,name,p[i].author);
return;
}
}
printf(%s책은 없습니다\n,name);
}
void cheap(struct Book p[], int n){
int i;
int che = p[0].price;
for(i=1;in;i++)
if(che p[i].price ){
che = p[i].price;
}
printf(책 값이 제일 싼 책 이름은 %s이고 가격은 %d원입니다\n,p[i].title,che);
}
void longPages(struct Book p[], int n){
int i;
int longP = p[0].pages;
for(i=1;in;i++)
if(longPp[i].pages){
longP = p[i].pages;
}
printf(가장 긴 페이지 책 이름은 %s이고 페이지수는 %d페이지입니다.\n,p[i].title, longP);
}
int main(){
struct Book books[5];
int i;
char name[100];
int menu;
inputAll(5,books); /*책 5 권 입력*/
while(1){
printf(\n검색:1, 가장 싼 책:2, 가장 긴 책:3, 모두보기:4, 끝내기:5 );
scanf(%d,&menu);
switch(menu){
case 1:
printf(\n 검색할 책의 이름 );
scanf(%s,name);
find(name, books,5);
break;
case 2:
cheap(books,5);
break;
case 3:
longPages(books,5);
break;
case 4:
printAll(5,books);
break;
case 5:
return;
}
/*printAll(5,books)*/
}
}
오류는 나지 않는데요.. 실행결과값이 틀린 부분이 있어서요.. 최소페이지나 싼값을 출력하기는 했는데 그에 해당하는
책제목을 출력하는 부분에 오류가 나네요.. 한번 봐주세요..ㅜ
-
김애교
....주석이나 좀 달아주세요. 분석하는데 시간 오래걸리는건 사람들 안합니다. ㅡ_ㅡㅋ