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
write a program to update the rate by increasing 20% from sequential data file "items.dat" that store item name.rate and quantit
sveticcg [70]

Answer:

your answer is in the pic

(◔‿◔)

。◕‿◕。

6 0
2 years ago
A technique for identifying and tracking assets using technologies such as RFID and smart cards is known as electronic tagging.
Mademuasel [1]

Answer: True

Explanation: Electronic tagging is defined as the activity in which the monitoring of the things and people are done through the electronic markers or device .This process is usually done by attaching a tag sized component on the ankle of the human to monitor them.

The tracking of the good and human is done by production of the time alerts through the tag .Thus the statement given in the question is true.

4 0
3 years ago
Describe how a black and white image could be represented in binary
SIZIF [17.4K]

Answer:

Each pixel in an image is made up of binary numbers. If we say that 1 is black (or on) and 0 is white (or off), then a simple black and white picture can be created using binary. To create the picture, a grid can be set out and the squares coloured (1 – black and 0 – white).

5 0
3 years ago
Read 2 more answers
Does any of yall know how to delete your account?
il63 [147K]

Answer:

No i really don't but why would you want to delete your account

8 0
2 years ago
Grid computing is a type of computing in which:
fredd [130]

Answer:

b

Explanation:

A computing grid can be thought of as a distributed system with non-interactive workloads that involve many files.

7 0
2 years ago
Other questions:
  • Which of the following is designed to help an organization continue to operate during and after a disruption?
    12·1 answer
  • ______ is using material created by others without obtaining permission from the original authors.
    10·2 answers
  • A sentinel value ________ and signals that there are no more values to be entered:____
    14·1 answer
  • What is a computer attack where an attacker accesses a wireless computer network, intercepts data, uses network services, and/or
    7·1 answer
  • Select the correct answer.
    10·1 answer
  • Frank enters "1" in the field for postal code. What is frank most likely trying to do?
    13·2 answers
  • Which of the following is an example of an incremented sequence?
    13·1 answer
  • Why is translator required?​
    11·2 answers
  • 15. Question
    12·1 answer
  • What are backup storage devices of computer? Why are they necessary in the computer system?​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!