#include const string animals[] = { "aardvark", "albatross", "alligator", "amoeba", "ant", "anteater", "antelope", "armadillo", "baboon", "bat", "bear", "bee", "beetle", "butterfly", "caprimulgus", "caribou", "carp", "cat", "caterpillar", "chicken", "chimpanzee", "cod", "cougar", "cow", "crab", "crocodile", "deer", "dingo", "dog", "dolphin", "dove", "duck", "eagle", "eel", "elephant", "elk", "ferret", "flamingo", "flounder", "frog", "gerbil", "giraffe", "gnu", "goat", "goldfish", "gorilla", "haddock", "hamster", "hawk", "hedgehog", "hen", "hippopotamus", "hyaena", "iguana", "jackass", "kangaroo", "koala", "lamprey", "lemur", "leopard", "lion", "llama", "lobster", "monkey", "moose", "mosquito", "moth", "mouse", "nematode", "newt", "octopus", "opossum", "orangutan", "osprey", "otter", "owl", "panda", "panther", "peacock", "penguin", "pheasant", "pigeon", "pig", "porcupine", "prairie-dog", "quagga", "quail", "rabbit", "racoon", "rat", "rhinoceros", "salamander", "sea-urchin", "seahorse", "seal", "sealion", "semicolon", "shark", "shrimp", "skunk", "snake", "sphynx", "spider", "squid", "squirrel", "starfish", "tapeworm", "tiger", "tortoise", "tuna", "turkey", "turtle", "unicorn", "varmint", "vole", "vulture", "walrus", "warthog", "weasel", "weevil", "whale", "woodlouse", "woodpecker", "worm", "yeti", "zebra", "zebu" }; const int number = sizeof(animals) / sizeof(string); const int prices[] = { 14137, 6378, 3918, 22088, 4854, 22069, 5620, 15666, 14841, 22983, 16273, 28698, 29951, 17292, 23205, 20857, 21438, 6829, 12064, 9336, 2406, 11874, 3413, 20643, 25750, 20292, 15083, 17632, 29907, 28287, 15184, 9396, 4665, 13454, 1484, 3871, 5523, 1456, 18538, 19364, 23439, 4811, 18062, 18742, 21103, 6620, 4951, 7893, 7801, 16016, 11581, 9207, 26890, 13994, 24203, 22641, 28639, 9286, 5625, 23898, 2926, 19809, 27646, 6591, 3264, 23482, 9463, 3139, 23938, 22353, 21504, 12729, 26164, 9566, 25824, 12619, 15186, 29775, 14865, 21987, 15791, 25446, 25547, 8034, 4793, 19750, 25027, 3432, 23388, 25004, 21682, 25314, 10166, 19328, 26258, 7782, 8162, 5721, 9921, 2100, 22426, 1425, 9181, 18590, 5344, 5005, 25561, 19530, 29133, 10426, 6870, 10276, 5873, 2417, 17310, 5018, 16519, 7689, 2802, 5259, 2694, 23484, 29574, 7212, 8164, 25832, 13994 }; const int pnumber = sizeof(prices) / sizeof(int); int find(string Q, const string names[], int start, int end, int count) { if (start > end) return -1; if (names[start] == Q) { print("it took "); print(count + 1); print(" steps\n"); return start; } return find(Q, names, start+1, end, count+1); } void main() { print("number of animals is "); print(number); new_line(); print("number of prices is "); print(pnumber); new_line(); print("search for: "); const string wanted = read_string(); const int position = find(wanted, animals, 0, number-1, 0); print("found it at position "); print(position); print(" the price is "); print(prices[position]); print(" cents\n"); if (position > 0) { print("just after "); print(animals[position-1]); new_line(); } if (position < number-1) { print("just before "); print(animals[position+1]); new_line(); } }