1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Elina [12.6K]
3 years ago
8

Write a program that reads a list of words. Then, the program outputs those words and their frequencies. If the input is 5 hey h

i Mark hi mark (the first number indicates the number of words that follow), the output is:
hey 1
hi 2
Mark 1
hi 2
mark 1

Hint: Use two vectors, one for the strings, another for the frequencies.

Your program must define and use the following function: int GetFrequencyOfWord(vector wordsList, string currWord)
Computers and Technology
1 answer:
zysi [14]3 years ago
4 0

Answer:

/ declare the necessary header files.

#include <iostream>

#include <string>

#include <vector>

using namespace std;

// declare the main function.

int main()

{

// declare a vector.

vector<string> words;

vector<int> counts;

// declare variables.

int size;

string str;

cin >> size;

// start the for loop.

for(int i = 0; i < size; ++i)

{

// input string.

cin >> str;

words.push_back(str);

}

// start the for loop.

for(int i = 0; i < size; ++i)

{

int count = 0;

// start the for loop.

for(int j = 0; j < words.size(); ++j)

{

// check the condition.

if(words[j] == words[i])

{

count++;

}

}

counts.push_back(count);

}

// start the for loop.

for(int i = 0; i < size; ++i)

{

// display result on console.

cout << words[i] << "\t" << counts[i] << endl;

}

return 0;

}

Explanation:

You might be interested in
Steve left his computer switched on in his room and went out to have breakfast. When he returned, he saw that the monitor had be
yanalaym [24]

Answer:

B

Explanation:

5 0
3 years ago
Rocks created from compaction and cementation of sediments are called:
Effectus [21]

Answer:

Sedimentary Rocks

Explanation:

Sedimentary rocks are essentially the Frankenstein monsters of the rock world. They're made up of pieces of igneous and metamorphic rocks, sand, clay, and other sedimentary rocks.

4 0
2 years ago
The number 84 is divisible by 2,3,4 and 6. true or false
Eva8 [605]
84÷2=42. 84÷3=28. 84÷4=21. 84÷6=14. So your answer is true.
8 0
3 years ago
Read 2 more answers
QUESTION 11
tino4ka555 [31]

Answer:

x == 32

Explanation:

CODE in Java:

       int x = 32;

       if(x == 32){

           System.out.println("Pass");

       }

       else{

           System.out.println("Fail");

       }

OUTPUT:

Pass

8 0
2 years ago
The __________ energy in food is changed into mechanical energy by your muscles.
qwelly [4]
The chemical energy in food is transformed into mechanical energy through a process called respiration. This isn't really a computers and technology question though. Try Biology next time.
4 0
2 years ago
Other questions:
  • Which functions are performed by server-side code??​
    10·1 answer
  • In a program called Nature's Notebook, citizen volunteers make and report observations about seasonal changes in plants and anim
    15·1 answer
  • Which measure should you take for the periodic maintenance of your computer? You need to invest in a for_______________ the peri
    15·2 answers
  • What did basic elements of music look like in the Twentieth Century period?
    6·1 answer
  • The Internet and World Wide Web allow almost any business to be global. What are two important results of this process?
    8·1 answer
  • Complete the paragraph describing characteristics of an audio mixer
    8·2 answers
  • Why is it important to brain storm and develop concepts prior to selecting an idea that you wish to move forward with as a solut
    7·1 answer
  • Write a program that asks a user to enter a date in month day year format (for example 10 12 2016) and displays the day of the w
    5·1 answer
  • Which of the following best describes the basic purpose of the internet?
    11·1 answer
  • Help me please. I'LL MARK BRAINIEST
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!