Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <iterator>
- #include <fstream>
- using namespace std;
- int input_cmp(std::string a, std::string b) {
- char choice;
- cout << a << " < " << b << " (y/n): ";
- cin >> choice;
- if (tolower(choice) == 'y') return -1;
- return 0;
- }
- #define SORT_TYPE std::string
- #define SORT_CMP input_cmp
- #define MG_SIZE 212
- void copy_array(SORT_TYPE *a, SORT_TYPE *b, int n) {
- for (int i = 0; i < n; i++) {
- a[i] = b[i];
- }
- }
- void merge(SORT_TYPE *a, int left, int right, int end, SORT_TYPE *b) {
- int i = left, j = right;
- for (int k = left; k < end; k++) {
- if (i < right && (j >= end || SORT_CMP(a[i], a[j]) < 0)) {
- b[k] = a[i];
- i++;
- } else {
- b[k] = a[j];
- j++;
- }
- }
- }
- void merge_sort(SORT_TYPE *a, int begin, int end, SORT_TYPE *b) {
- if (end - begin < 2) return;
- int mid = (begin + end) / 2;
- merge_sort(b, begin, mid, a);
- merge_sort(b, mid, end, a);
- merge(b, begin, mid, end, a);
- }
- int main() {
- std::string girls[MG_SIZE] = {"Akaname","Alice","Alp","Alraune","Amazoness","Angel","Ant Arachne","Anubis","Apophis","Apsara","Arachne","Arch Imp","Atlach-Nacha","Automaton","Baphomet","Barometz","Basilisk","Beelzebub","Bicorn","Black Harpy","Blue Oni","Bubble Slime","Bunyip","Cait Sith","Cancer","Centaur","Charybdis","Cheshire Cat","Chimaera","Chochin-Obake","Cockatrice","Crow Tengu","Cu Sith","Cupid","Cursed Sword","Cyclops","Dark Angel","Dark Elf","Dark Mage","Dark Matter","Dark Priest","Dark Slime","Dark Valkyrie","Demon","Devil","Devil Bug","Dhampir","Doppelganger","Dormouse","Dorome","Dragon","Dragon Zombie","Dryad","Dullahan","Dwarf","Echidna","Elf","Fairy","Familiar","Flow Kelp","Gandharva","Gargoyle","Gazer","Ghost","Ghoul","Giant Ant","Giant Slug","Girtablilu","Glacies","Gnome","Goblin","Golem","Greenworm","Gremlin","Griffon","Grizzly","Gyoubu Danuki","Hakutaku","Harpy","Hellhound","High Orc","Hinezumi","Hobgoblin","Holstaur","Honey Bee","Hornet","Houri","Humpty Egg","Ice Queen","Ignis","Imp","Inari","Ittan-momen","Jabberwock","Jiangshi","Jinko","Jinn of the Jar","Jorou-Gumo","Jubjub","Kakuen","Kamaitachi","Kappa","Karakasa-Obake","Kejourou","Kesaran Pasaran","Khepri","Kikimora","Kitsune-bi","Kitsune-tsuki","Kobold","Kraken","Kunoichi","Lamia","Large Mouse","Lava Golem","Leanan Sidhe","Lesser Succubus","Lich","Lilim","Liliraune","Living Armor","Living Doll","Lizardman","Mad Hatter","Mandragora","Manticore","Mantis","March Hare","Matango","Medusa","Mermaid","Merrow","Mershark","Mimic","Mindflayer","Minotaur","Mothman","Mucus Toad","Mummy","Nekomata","Nereid","Night Gaunt","Nightmare","Nurarihyon","Nureonago","Ochimusha","Ogre","Oomukade","Orc","Otohime","Owl Mage","Papillon","Parasite Slime / Slime Carrier","Phantom","Pharaoh","Pixie","Queen Slime","Raiju","Ratatoskr","Red Oni","Red Slime","Redcap","Ren Xiongmao","Roper","Ryu","Sahuagin","Salamander","Sandworm","Satyros","Scylla","Sea Bishop","Sea Slime","Selkie","Shirohebi","Shoggoth","Siren","Skeleton","Slime","Soldier Beetle","Sphinx","Succubus","Sylph","Tentacle","Thunderbird","Titania","Tritonia","Troll","Trumpart","Umi Osho","Unagi Joro","Undine","Unicorn","Ushi-Oni","Valkyrie","Vamp Mosquito","Vampire","Wendigo","Werebat","Werecat","Wererabbit","Weresheep","Werewolf","White Horn","Wight","Will-o-the-Wisp","Witch","Wurm","Wyvern","Yeti","Youko","Yuki-Onna","Zombie"};
- reverse(begin(girls), end(girls));
- SORT_TYPE tmp[MG_SIZE];
- copy_array(tmp, girls, MG_SIZE);
- merge_sort(girls, 0, MG_SIZE, tmp);
- fstream f;
- f.open("sorted monster girls.txt", fstream::out);
- if (!f.is_open()) {
- cerr << "failed to open output file\n";
- exit(1);
- }
- cout << "\n";
- for (int i = 0; i < MG_SIZE; i++) {
- f << girls[i] << "\n";
- cout << girls[i] << "\n";
- }
- f.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement