#include <stdio.h>

struct profile{
char name[5];
int age;
int sex;
};

struct bimando{
float weight;
float height;
double sum,biman_check;
};

typedef struct profile PRO;
typedef struct bimando BIMAN;

void candy(void);

int main(void){
PRO a,*Diet;
BIMAN b,*Diet1;
float alpa;
Diet=&a;
Diet1=&b;

candy();

printf(\"이름을 입력하시오:\");
gets(a.name);
printf(\"나이를 입력하시오:\");
scanf(\"%d\",&a.age);
printf(\"성별을 입력하시오 =>남자 1번 여자 2번:\");
scanf(\"%d\",&a.sex);
if(a.sex ==1)
alpa=22.0;
else
alpa=21.0;

printf(\"키를 입력하세요 :\");
scanf(\"%f\",&b.height);
printf(\"몸무게를 입력하세요 :\");
scanf(\"%f\",&b.weight);
printf(\"\\n\");

 b.sum = (b.height*0.01)*(b.height*0.01)*alpa;
 b.biman_check= (b.weight/b.sum)*100.0;

printf(\" %s 님의 비만도 측정 결과 입니다.\\n\",Diet->name);


printf(\"\\n표준체중: %.2f\\n\",b.sum);
printf(\"\\n비만도: %.2f\",b.biman_check);


if(b.biman_check >120)
printf(\"비만 입니다.\");
else if(b.biman_check > 110 && b.biman_check <120)
printf(\"과체중 입니다.\");
else if(b.biman_check > 90 && b.biman_check <110)
printf(\"보통 입니다.\");
else
printf(\"체중 미달입니다.\");

printf(\"\\n\");

return 0;
}

void candy(void){
FILE *food;
food=fopen(\"foodyo.txt\",\"w\");
fprintf(food, \"다이어트에 좋은 음식 :1.김치찌개 2.된장찌개 3.닭고기 4.우유 5.달걀 6.녹색채소\");
fclose(food);
}

 



 

1. 배열
2. 포인터
3. 사용자정의함수
4. 구조체
5. 파일입출력
6. typedef
7. 동적할당(malloc() 또는 calloc() ~ free())
8. srand(time(NULL))과 rand()

---------------------------------------------------
위 8가지가 모두 포함된 프로그램을 작성한 후 제출하시오.





과제가 이건데 1~6번까지는 제가 어떻게 억지로 껴서 넣엇는데
7,8번을 어떻게 해야될지 모르겟슴메....
힌트좀 주세여