Блог пользователя Loser_

Автор Loser_, история, 5 лет назад, По-английски

1111A - Superhero Transformation I have tried map for tracking either a char is vowel or consonant.And then comparing both the map's element, I may have my expected solution.But implementing map it came to my mind that map is a sorted container.So I google it and from stackoverflow I found this articlefifo_map which actually acts according to plan.But using above mentioned way I have a compilation error(No such directory).Is there any way to include external headers? My submission is here

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

You could always use the reliable:

spoiler
  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    strchr is a C function. OP wants to do things in C++.

    • »
      »
      »
      5 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Well it works. Otherwise OP could use a normal if with 5 conditions.

      If he needs something with C++ he could use an unordered_set:

      unordered_set<char> vowels;
      vowels.insert('a');
      vowels.insert('e');
      vowels.insert('i');
      vowels.insert('o');
      vowels.insert('u');
      if(vowels.count(c) == 1)
          // c is a vowel
      else
          // c is a consonant
      
  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks a lot.I just kinda curious if I could solve it using map?

    • »
      »
      »
      5 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится
      unordered_map<char,bool> isVowel;
      
      isVowel['a'] = isVowel['e'] = isVowel['i'] = isVowel['o'] = isVowel['u'] = true;
      
      if(isVowel[c])
          // c is avowel
      else
          // c is a consonant
      
»
5 лет назад, # |
  Проголосовать: нравится +12 Проголосовать: не нравится

You're trying way too hard for a simple problem. You can solve without using unordered_map. I, as a rule of thumb, like to keep things simple wherever they can be kept simple. Even you should try very simple implementations. You should also note that CF will not store every available library implementation available on the internet. We have the STL here only so fifo_map.hpp isn't available, wherever you found it. To use an unordered_map, use the library implementation instead of a third party source.

So, in order to help you solve this problem:

Hint
Hint