help pleaseeeeeee help

Pages: 12
Assistant urgent
I want to work program language c + + so that it enters the user what he wants of the words, then the software will know how many times to repeat the word and arranged by descending order and writes the number of times to repeat each word

Please help urgent please

Please
a) Do the work yourself, then ask if you have a specific problem. Don't ask us to do your homework.
b) I have no idea what you're trying to do.

I try before that but i don,t win

and this i want to do it


for example:

Hello this is a test 1
Hello this is a test 2

output should be:
hello 2
this 2
is 2
a 2
test 2
1 1
2 1

Show us the code you already have then, so we can tell you what you did wrong.
Suspended you delete the code because he was constantly giving me errors

But I have used this program in each of the functions and Alasturnj used files and matrices, but also able to insert words

I was mad I have tried and tried to


But I have new hope that I can be resolved and sister but I have promised myself that has permitted this day please help me
D

I still Beginner
Use std::map in this way.

declare a std::stringstream ss;
put your input in ss.
std::string s;
while (ss >> s)
{
search the map if s is in your map then add 1 to the value,
if not add the key to the map and put 1 in it.
}
cout all key values in a loop

i tried not to write the fulll code, so you can try doing your homework yourself as Gaminic said.

Cheers,
Can you write me in the form of code

To learn I do not want you to explain but I will try and understand myself to learn
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
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <map>
#include <string>

using namespace std;

int main()
{
    map<string, int> stuff;
    string s, temp;

    cout << "Input your stupid string please:\n";

    getline(cin, temp);
    stringstream ss(temp);

    while (ss >> s)
      ++stuff[s];

    for (const auto &thing: stuff) // I hope you're not using Borland C lol
      cout << thing.first << ' ' << thing.second << '\n';

    cout << std::endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}


Don't worry people, he's lucky if he can compile it.
hahahahhaha

ok i try

but if i don, t win

i well back


Thanks
I konw in c++

loop
function
array
struct


just

bit i don,t no map and opp
i think you are gonna get a runtime error on this line when ever you are going to ++ an item that is not added to the map. am i mistaken?

while (ss >> s)
++stuff[s];
@ Farzam: program works fine for me.
The map's [] operator adds the item if it doesn't exist.
closed account (zb0S216C)
virus ha3 wrote:
ok i try

but if i don, t win

i well back (sic)

Wha'?

Wazzak
I get a
error: a function-definition is not allowed here before ':' token

on for (const auto &thing: stuff)
@ wtf: C++11 code. Use GNU C++.
I use codeblocks. still won't compile.
Please help me as fast as writing code and Full
I need it very
I use codeblocks. still won't compile.

Try using it with GCC (at least version 4.6).
Last edited on
Try using it with GCC (at least version 4.6).


And call the compiler with -std=c++0x.
Last edited on
I suggest you don't give assistance to anyone that are here with "Program instructions" and not the codes they wrote. It is not a forum where people are spoon-fed, you should be able to do your work and then ask for help.
Pages: 12