소스한번 봐주세요..ㅜ
민트맛캔디
#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)*/
}
}
오류는 나지 않는데요.. 실행결과값이 틀린 부분이 있어서요.. 최소페이지나 싼값을 출력하기는 했는데 그에 해당하는
책제목을 출력하는 부분에 오류가 나네요.. 한번 봐주세요..ㅜ
-
날개 2024-06-26
....주석이나 좀 달아주세요. 분석하는데 시간 오래걸리는건 사람들 안합니다. ㅡ_ㅡㅋ
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2670009 | #if #endif 질문입니다. (5) | 새솔 | 2024-09-29 |
2669952 | 구구단질문 | 독특한 | 2024-09-28 |
2669926 | 인텔CPU 명령어들...질문좀... (1) | 널위해 | 2024-09-28 |
2669899 | 회문검사 오류 | 꽃님이 | 2024-09-28 |
2669870 | 색인값 찾기를 만들었는데 봐주세여 ㅠ (1) | 아빠몬 | 2024-09-27 |
2669843 | 저기요 ㅠㅠ 이게 헤더파일 로써 갖추지 못 한게 뭐죠 ? ? ? (7) | AngelsTears | 2024-09-27 |
2669815 | 자료구조 덱에 대해 궁금한게있어요 | 흙이랑 | 2024-09-27 |
2669768 | 파일관련에 관한 질문인데요 ㅠㅠ (1) | 화가마 | 2024-09-26 |
2669722 | if문기초에요 ㅠ 누구든지오셔서 알려주세요 ㅠ | 황소자리 | 2024-09-26 |
2669696 | add(&imsi,lenth);는 안되는이유! | 겨울 | 2024-09-26 |
2669635 | 문제좀 ..풀어주세요 ㅠㅠ (4) | 볼매 | 2024-09-25 |
2669608 | C언어를 배우고 이쓴데 /n이 말을 안듣네요;; (2) | 희나리 | 2024-09-25 |
2669581 | 다차원문자열배열과 입출력 (1) | 볼수록매력 | 2024-09-25 |
2669555 | 최대값 최소값 구하는 방법 알려주세요. (2) | 아연 | 2024-09-25 |
2669449 | float 와 double의 차이점 해석하는것좀 도와주세요~~ | 초롬 | 2024-09-24 |
2669426 | 퀵 정렬 소스에 대해서.. | 키클 | 2024-09-24 |
2669399 | %s로 문자열 호출 안하면 코드가 종료되는 이유 | 아이뻐 | 2024-09-23 |
2669342 | 랜덤발생기인데요 (3) | 카제 | 2024-09-23 |
2669309 | 소켓 통신 recv 할때 질문합니다. | 미투리 | 2024-09-23 |
2669264 | fscanf 도와주세요,... (3) | 볼수록매력 | 2024-09-22 |