-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path2083.c
75 lines (67 loc) · 1.48 KB
/
2083.c
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
73
74
75
// [ 백준 ] 2083번: 럭비 클럽
#include <stdio.h>
#include <string.h>
char *BREAK_POINT_NAME = "#";
int BREAK_POINT_AGE = 0;
int BREAK_POINT_WEIGHT = 0;
int SENIOR_AGE = 17;
int SENIOR_WEIGHT = 80;
char *SENIOR = "Senior";
char *JUNIOR = "Junior";
typedef struct
{
int age;
int weight;
char name[11];
} Member;
int IsBreakPoint(char *name, int age, int weight)
{
if (
strcmp(name, BREAK_POINT_NAME) == 0
&&
age == BREAK_POINT_AGE
&&
weight == BREAK_POINT_WEIGHT
) {
return 1;
}
return 0;
}
Member *CreateMember(char *name, int age, int weight)
{
Member *member = malloc(sizeof(member));
strcpy(member -> name, name);
member -> age = age;
member -> weight = weight;
return member;
}
char *GetMemberType(Member *member)
{
if (
member -> age > SENIOR_AGE
||
member -> weight >= SENIOR_WEIGHT
) {
return SENIOR;
}
return JUNIOR;
}
void PrintMemberType(Member *member)
{
char *type = GetMemberType(member);
printf("%s %s\n", member -> name, type);
free(member);
}
int main(void)
{
while (1) {
char name[11];
int age, weight;
scanf("%s %d %d", &name, &age, &weight);
if (IsBreakPoint(name, age, weight) == 1) {
break;
}
Member *member = CreateMember(name, age, weight);
PrintMemberType(member);
}
}