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
What is the most popular type or method of guaranteed reservation where booking transactions will be charged automatically?
Rzqust [24]

Answer:

Credit cards.

Explanation:

When booking a reservation, the most popular type or method of making sure the reservation is guaranteed where booking transactions are charged automatics is the use of credit cards.

Why this is popular is because, the hotel, reserve or suite that is about to be booked will still receive their money even if the person that booked didn't show up.

4 0
3 years ago
A Portable Document Format (PDF) can be opened with Adobe Acrobat Reader and many web browsers.
natka813 [3]

Answer:

True

Definition / Directions:

A PDF is a file format that provides an electronic image of text or text and graphics that looks like a printed document and can be viewed, printed, and electronically transmitted.

How to Open a PDF:

Open the Adobe Reader or any other PDF software program. Then, click the file menu near the top on the left side of the window, select Open, and browse to the location of the PDF file. Select the file you want to open by clicking the file name, and then click the Open button to open the file.

6 0
3 years ago
What is the purpose and what are some of the components of a wide area network connection?
Ilia_Sergeevich [38]

Answer:

WAN(wide area network) is the network that is used for the connection in the geographical areas on large scale.They are used for connecting the areas like cities, countries, states etc.The connection of various LANs(Local area network) and MAN(Metropolitan area network) form the WAN.

There are several components that are used in the wide area network structure. Some of the constituents are as follows:-

  • ATM()Asynchronous transfer mode
  • Fiber optic communication path
  • Modem having cables
  • Frame relay
  • Dial up internet etc.

5 0
3 years ago
Read 2 more answers
What is the purpose of linking text boxes?
Neko [114]
The answer that the person answered is the same answer I was gonna answer so Yh it’s correct
5 0
3 years ago
___ is the most important variable that is measured and controlled in a commercial hvac system.
Pavel [41]

The parameter being monitored and controlled is the controlled variable. The dry-bulb temperature of the air leaving the cooling coil is the controllable variable in this particular instance. The sensor assesses the state of the controlled variable and provides the controller with an input signal.

<h3>What is a HVAC ?</h3>

The employment of various technologies for heating, ventilation, and air conditioning is done to regulate the temperature, humidity, and cleanliness of the air in a closed environment. Its objective is to provide adequate indoor air quality and thermal comfort.

  • To cool or heat a building, the main unit of a ducted system forces air via a network of air ducts. On the other hand, ductless systems don't have air ducts and employ different techniques to spread cleaned air across a room.

Learn more about HVAC system here:

brainly.com/question/20264838

#SPJ4

6 0
2 years ago
Other questions:
  • Which of the following is not an important consideration before a business invests in a particular technology?
    12·1 answer
  • The following code in a different program is not working properly. The message should display the value of the intCounter variab
    14·1 answer
  • Match the terms related to the web with their explanations
    6·1 answer
  • Being able to download a chapter of a new book before buying it, or listening to a few seconds of a song before purchasing it ar
    7·1 answer
  • EASY AND I GIVE BRAINLIEST!!! What is a good jeopardy question about operating systems?
    6·1 answer
  • public class Ex0506 { public static void main (String args[]) { int x = 2; while (x &lt; 10) { if (x % 2 == 0) x+=3; else x+=2;
    15·1 answer
  • Gigantic Life Insurance is organized as a single domain. The network manager is concerned that dividing into multiple domains to
    15·1 answer
  • How many sections of a job description are there
    5·1 answer
  • Joseph wants to take out the color of the background wall from an image what can Joseph do to achieve this​
    5·2 answers
  • In your own words, describe invention.
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!