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]
4 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]4 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
The bantu and arabic languages blended, creating what new language?
Anon25 [30]
The answer is swahili

Basically, the Swahili language is of an African Bantu origin with borrowed words from other languages like Arabic. It dates back to the interactions between the Arabian traders and the inhabitants of the east coast of Africa. The language was often thought to be an interaction between Bantus and Arabs. Arab cultures had a huge influence on the Swahili language.




5 0
4 years ago
Read 2 more answers
Anyone here codes? <br> C++, C#, Lua? Anything?
Travka [436]

Answer:

IxxyzjgzkgzjgKfzkg v

jvljcljxkhxkgg/gjhkggzkykzkgjzjgggggzjgcufxu

Explanation:

nk yxthzefhGghghrhgzxhhsdgchiixxu

7 0
3 years ago
Read 2 more answers
What helps in determining the reliability of a person to repay debt?
faust18 [17]

C. The amount of credit score

3 0
3 years ago
Read 2 more answers
U.S. cybersecurity experts and government officials are increasingly concerned about breaches from __________ into corporate net
Triss [41]

Answer:

Organized crime syndicates based in the United State

Explanation:

U.S. cybersecurity experts and government officials are increasingly concerned about breaches from organized crime syndicate based in the United States into corporate networks, either through mobile devices or by other means.

The crime syndicate can go to any length to access corporate network through mobile device or any other means in order to commit crimes that is why the US cyber security expert and government officials are increasingly concerned.

Cyber security specialists or expert in the US are been employed to protect information or data that the crime syndicate may want to gain access to by using different variety of techniques by critically monitoring the systems network for attempted breaches by the crime syndicates and then dealing with any of them that is found guilty.

5 0
3 years ago
I have a question about a hotel tv:
UNO [17]

1 Open the back cover of the Nintendo Switch Dock.

2 Connect the USB plug from the Nintendo Switch AC adapter (model No. ...

3 Connect one end of the HDMI cable into the bottom terminal of the dock labeled "HDMI OUT," then connect the other end into an HDMI port on your television or monitor.

                                                                                                   your welcome

3 0
3 years ago
Other questions:
  • What is one rover that landed on mars but not pathfinder or curosity?
    12·2 answers
  • Earthquakes happen in the Earth’s
    10·1 answer
  • Which of the following STEM discoverers developed a new type of computer hardware?
    11·1 answer
  • In Word, the default typing mode is ____ mode, which means as you type a character, Word moves all the characters to the right o
    14·2 answers
  • 12.
    10·1 answer
  • A wall is built of bricks. What force is being applied to each brick from the bricks above? ​
    7·1 answer
  • 3. The channel bit error rate is 0.00001, and each packet’s total length is 1024 bytes including all overheads. Assume there are
    12·2 answers
  • A phonebook typically lists the name, address, and telephone number of everyone living in an area. Write code defining a structu
    15·1 answer
  • How to write (c program) code for 30/4 = 7.5. It should print 7.5, not 7
    12·1 answer
  • What is not one of the top health concerns in the United States?physical activitymental healthtobacco useaccess to education
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!