Created
June 24, 2023 15:18
-
-
Save Alex4386/3e49b4cafc537530dd972eff23a92bb6 to your computer and use it in GitHub Desktop.
아보카도 있었어
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "mart.h" | |
int main() { | |
// 여보 마트가서 | |
// 우유 사고 | |
Good target_good = GOODTYPE_MILK; | |
int quantity = 1; | |
// 만약에 아보카도 있으면 | |
int avocado_quantity = fetch_quantity(GOODTYPE_AVOCADO); | |
if (avocado_quantity > 0) { | |
// 여섯개 사와 | |
quantity = 6; | |
} | |
// 아보카도 있었어 | |
buy(target_good, quantity); | |
if (avocado_quantity > 0) { | |
printf("아보카도 있었어.\n"); | |
} else { | |
printf("아보카도 없었어.\n"); | |
} | |
// Non-0 exit condition: Caused by 등짝 스매싱 | |
return 1; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "mart.h" | |
int fetch_quantity(Good good) { | |
if (good == GOODTYPE_AVOCADO) return 1; | |
} | |
int buy(Good good, int quantity) { | |
printf("[BUY] %s를 %d개 구매했습니다.\n", get_localized_good_name(good), quantity); | |
return 1; | |
} | |
char* get_localized_good_name(Good good) { | |
char *string = NULL; | |
switch (good) { | |
case GOODTYPE_AVOCADO: | |
string = "아보카도"; | |
break; | |
case GOODTYPE_MILK: | |
string = "우유"; | |
break; | |
} | |
return string; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __MART_H__ | |
#define __MART_H__ | |
typedef enum _Good { | |
GOODTYPE_MILK, | |
GOODTYPE_AVOCADO | |
} Good; | |
int fetch_quantity(Good good); | |
int buy(Good good, int quantity); | |
char* get_localized_good_name(Good good); | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment