Jumble word through user input


(Jumble word program) (plz guys help me to make this program)

user enter few characters randomly, then press enter, (your program stores 50 names of your class fellows)
if by rearranging your entered characters it matches to the names stored,
then it will show it, otherwise it will show that name does not exist.

for example.... user enter llohe
correct name already declare (hello) program show this name





Create a structure that keeps track of the name as well as the count of letters:
1
2
3
4
5
struct Person
{
  std::string name;
  std::map< char, int > letter_count;  // or even int letter_count[26]
};


When you collect a string from the user, count the letters and then look through the database for names with the same amount of letters.

Do not try to rearrange the letters looking for a match, just show that the it would be possible to rearrange them.
can you help me to make this program for me.this is my assignment. and i have no idea how i make this program. plz help me to make this.
http://www.cplusplus.com/articles/DjGEy60M/

We don't solve homework problems or reply to posts that ask people to write a program for their assignment. We will be glad to help you as long as it is YOU that is doing the work yourself.
Last edited on
IceStorm wrote:
We don't solve homework problems or reply to posts that ask people to write a program for their assignment.

Really? What is it you just did?

Sometimes we might supply a solution that is a little beyond the reach of the OP:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// http://ideone.com/8mjq2T
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <string>

struct text
{
    text() = default;
    text(const std::string& txt) : data(txt) {}

    std::string key() const { std::string k(data); std::sort(k.begin(), k.end()); return k; }

    operator std::pair<std::string, std::string>() const { return std::make_pair(key(), data); }

    std::string data;
};

std::istream& operator>>(std::istream& is, text& t)
{
    return is >> t.data;
}

std::ostream& operator<<(std::ostream& os, const text& t)
{
    return os << t.data;
}

std::string quoted(const text& t)
{
    return std::string(1, '"') + t.data + '"';
}

int main()
{
    using pair_type = std::pair<std::string, std::string> ;

    std::unordered_map<std::string, std::string> map =
    { 
        pair_type(text("scooby")), pair_type(text("shaggy")),  pair_type(text("veronica")),
        pair_type(text("fred")),   pair_type(text("daphne")),  pair_type(text("wilma")),
        pair_type(text("betty")),  pair_type(text("barney")),  pair_type(text("dino")),
        pair_type(text("bambam")), pair_type(text("pebbles")), pair_type(text("george"))
    };

    text t;

    while (std::cin >> t)
    {
        auto it = map.find(t.key());
        if (it != map.end())
            std::cout << quoted(t) << " matches " << quoted(it->second) << '\n';
        else
            std::cout << quoted(t) << " matches nothing\n";
    }
}
thank you very much, for sharing
but still problem is that
#include <unordered_map>
unordered_map error in my compiler and have no such library file in my compiler... i use Dev c++ 5.6 version
thank you very much. i resolve the problem and program work perfectly.
but i problem is that this program beyond my level. can you please help me to explain how is it work or make it beginning level.
Topic archived. No new replies allowed.