레스토랑을 표현하는 구조체를 만들어야하거등요..
구주체안에 이름 주소,평균비용이랑 음식의 유형을 나타내는 멤버를 포함해야 하구요...
배열이 만들어지면..
가장비싼음식을 찾아서 출력하는 프로그램을 만드는건데...
대충 만들었는데 에러가 뜹니다...ㅠㅠ
좀 봐주셔요..ㅠㅠ
#include <stdio.h>
#define SIZE 2
struct food{
char fd_name[20]; //음식 이름
int price; //음식 가격
};
struct restaurant {
char name[20]; // 레스토랑 이름
char **address; // 주소
int sum; // 합으로 나중에 평균을 구함
struct food fd[10]; // 음식
};
typedef struct restaurant rest;
void main()
{
rest rest[SIZE];
int i, j;
int r_max = 0, f_max = 0 , kind[SIZE]; //처음을 max 로 지정
for(i = 0 ; i < SIZE ; ++i){
printf("레스토랑 이름을 입력하세요n");
scanf("%s", &rest[i].name);
printf("주소를 입력하세요n");
scanf("%s", rest[i].address);
printf("음식 종류가 몇가지입니까?n");
scanf("%d", &kind[i]);
rest[i].sum = 0 ; // sum을 0으로 초기화
for(j= 0 ; j < kind[i] ; ++j){
printf("음식과 가격을 입력하세요n");
scanf("%s %d", &rest[i].fd[j].fd_name, &rest[i].fd[j].price);
rest[i].sum += rest[i].fd[j].price ;
}
printf("nnn");
}
for(i=1 ; i < SIZE ; ++i)
for(j = 0 ; j < kind[SIZE] ; ++j)
if(rest[r_max].fd[f_max].price < rest[r_max].fd[f_max].price)
r_max = i ; f_max = j ; //max[0] = 레스토랑 , max[1] = 음식
printf("가장 비싼 음식이 있는 레스토랑!n");
printf("%s t %s ttttt %s t %s n", "레스토랑 이름",
"주소", "비싼 음식", "가격");
printf("%s t %s ttttt %s t %d n",rest[r_max].name, rest[r_max].address,
rest[r_max].fd[f_max].fd_name, rest[r_max].fd[f_max].price);
}