From c80a6294e1c75d867ac8e3a74b41e4c4b60e98d2 Mon Sep 17 00:00:00 2001 From: Dmitry Kokorin Date: Mon, 29 Feb 2016 14:56:08 +0300 Subject: [PATCH] food_chain: 3-column table --- cpp/food-chain/food_chain.cpp | 38 +++++++++++++++-------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/cpp/food-chain/food_chain.cpp b/cpp/food-chain/food_chain.cpp index 56dff57..4e7f2fb 100644 --- a/cpp/food-chain/food_chain.cpp +++ b/cpp/food-chain/food_chain.cpp @@ -6,39 +6,33 @@ namespace food_chain { using namespace std; -#define ANIMAL_TABLE \ -X(Fly, "fly") \ -X(Spider, "spider") \ -X(Bird, "bird") \ -X(Cat, "cat") \ -X(Dog, "dog") \ -X(Goat, "goat") \ -X(Cow, "cow") \ -X(Horse, "horse") +#define ANIMAL_TABLE \ +X(Fly, "fly", "") \ +X(Spider, "spider", "It wriggled and jiggled and tickled inside her.\n") \ +X(Bird, "bird", "How absurd to swallow a bird!\n") \ +X(Cat, "cat", "Imagine that, to swallow a cat!\n") \ +X(Dog, "dog", "What a hog, to swallow a dog!\n") \ +X(Goat, "goat", "Just opened her throat and swallowed a goat!\n") \ +X(Cow, "cow", "I don't know how she swallowed a cow!\n") \ +X(Horse, "horse", "She's dead, of course!\n") -#define X(a, b) a, +#define X(a, b, c) a, enum Animal { - ANIMAL_TABLE + ANIMAL_TABLE }; #undef X -#define X(a, b) b, +#define X(a, b, c) b, static const char *animal_name[] = { - ANIMAL_TABLE + ANIMAL_TABLE }; #undef X - +#define X(a, b, c) c, static const char *verse_phrase[] = { - "", - "It wriggled and jiggled and tickled inside her.\n", - "How absurd to swallow a bird!\n", - "Imagine that, to swallow a cat!\n", - "What a hog, to swallow a dog!\n", - "Just opened her throat and swallowed a goat!\n", - "I don't know how she swallowed a cow!\n", - "She's dead, of course!\n" + ANIMAL_TABLE }; +#undef X string verse(int index)