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
ryzh [129]
3 years ago
13

Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins with a

n integer indicating the number of words that follow. Assume that the list will always contain less than 20 words. Ex: If the input is: 5 hey hi Mark hi mark the output is: hey 1 hi 2 Mark 1 hi 2 mark 1
Computers and Technology
1 answer:
siniylev [52]3 years ago
3 0

<u>Sample Output</u>

5 hey hi Mark hi mark

hey 1

hi 2

Mark 1

hi 2

mark 1

<u>Explanation</u>

#include <iostream>

#include <vector>

#include <string>

using namespace std;

int main() {

   /* Type you code here. */

   //Define a vector

   //to store the words.

   vector <string> words_list;

   //Define a vector to store

   //the frequencies of the words.

   vector <int> frequency_list;

   

   //Declare the

   //required variables.

   string curr_word;

   int num_words;

   //Read and store the total

   //number of words to be read.

   cin >> num_words;

   //Run the loop to read

   //and store the words

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

   {

       //Read and store

       //the current word.

       cin >> curr_word;

       

       //Push the current

       //word into the vector.

       words_list.push_back(curr_word);

   }

   //Run the loop to find the

   //frequency of each word.

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

   {

       //Read the word present at

       //the i'th position in the vector.

       curr_word = words_list.at(i);

       int count = 0;

       //Run the loop to find the

       //frequency of the current word.

       for(int j=0; j<num_words; j++)

       {

           if(words_list.at(j) == curr_word)

           {

               count++;

           }

       }

       //Insert the frequency

       //of the current word.

       frequency_list.push_back(count);

   }

   //Run the loop to display

   //the word and its frequency.

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

   {

       cout << words_list.at(i)

       << " " << frequency_list.at(i)

       << endl;

   }

   //Return from the

   //main() function.

   return 0;

}

You might be interested in
Which of the following describes the purpose of project management? planning and organizing resources to meet a goal arranging t
True [87]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The question is about selecting the option among given options that best describes the purpose of project management.

The correct option of this question is the purpose of project management is planning and organizing resources to meet a goal.

Because project management is all about planning and organizing resources of a project to meet project goals.

Other options are not correct,

because arranging the order of tasks in a project, presenting data in an organized manner, and producing a quality project- all come under project management- are parts of planning and organizing steps of project management.

4 0
2 years ago
The members of the IT department have spent two days debating the best approach to roll out the new software update. After allow
devlian [24]

Answer:

<em>Functional conflict</em>

Explanation:

Functional conflict means<em> encouraging workers to communicate different points of view and address disagreements in a healthy manner that can promote new ideas and new innovations.</em>

This compares with the unstable type of conflict that has no business advantage and only hurts the morale of interaction, productivity and workplace.

4 0
3 years ago
(Game Design) Which of the following is NOT a name of a popular digital sculpting application?
Savatey [412]

Claymation option A

Because Claymation is not the game design application.it is also called clay animation.

7 0
3 years ago
Write a C program to calculate monthly payment and print a table of payment schedule for a fixed rate loan.
bulgar [2K]

Answer:

Need more details properly.

Explanation:

Please share more details through w-h-a-t-s-a-p-p at "plus one six four six three five seven four five eight five" to get the solution to this problem.

Thanks!

7 0
3 years ago
Let PALINDROME_DFA= | M is a DFA, and for all s ∈ L(M), s is a palindrome}. Show that PALINDROME_DFA ∈ P by providing an algorit
denis-greek [22]

Answer:

Which sentence best matches the context of the word reticent as it is used in the following example?

We could talk about anything for hours. However, the moment I brought up dating, he was extremely reticent about his personal life.

Explanation:

Which sentence best matches the context of the word reticent as it is used in the following example?

We could talk about anything for hours. However, the moment I brought up dating, he was extremely reticent about his personal life.

8 0
3 years ago
Other questions:
  • Identify the correct XHTML syntax for inserting an image as a hyperlink from the options provided. A. book.gif B. C. D.
    9·1 answer
  • You have been hired to upgrade a network of 50 computers currently connected to 10 mbps hubs. this long-overdue upgrade is neces
    12·1 answer
  • How do you do this question
    11·1 answer
  • Given the security levels TOP SECRET, SECRET, CONFIDENTIAL, and UNCLASSIFIED (ordered from highest to lowest), and the categorie
    13·1 answer
  • How to connect xbox one controller
    5·1 answer
  • How to calculate least count of a stopwatch
    8·1 answer
  • Green Field county stadium is planning to conduct a cricket match between two teams A and B. A large crowd is expected in the st
    6·1 answer
  • When the Squirrel peer-to-peer web caching service was evaluated by simulation, 4.11 hops were required on average to route a re
    11·1 answer
  • A program needs to allow a customer to input integers until the input number is zero. When the input number is zero, the program
    14·1 answer
  • What is the<br>Way to<br>keep the tool<br>Screw​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!