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
Drag each tile to the correct box.
V125BC [204]

Answer:

Creates order and harmony → <em>color</em>

Creates an emotional impact → <em>texture</em>

Brings a feeling of depth to a design →<em> form</em>

Draws or minimizes attention → <em>space</em>

Divides space and redirects the eye → <em>shape</em>

Explanation:

The visual element that creates order and harmony is <em>color</em>

Color can be used to create visible patterns that can be recognized as being in harmony or disagreement

The visual element that creates emotional impact is <em>texture</em>

Texture can be used to convey either the emotions of the object or the artist

The visual element that brings a feeling of depth to a design is<em> form</em>

Form is used to present a 3-D appearance of an art, and therefore, it is used to show depth of a 2-D drawing

The visual element that draws or minimizes attention is <em>space</em>

The arrangement, location, and size of the space occupied by an object can be used to draw or minimize attention

The visual element that divides space and redirects the eye is <em>shape</em>

Shape is used to divide space into areas easily recognizable by the eye

5 0
2 years ago
Based on the unit content and your own ideas, how would you define a video game in your own words? What separates a regular vide
lara31 [8.8K]

Answer:

A video game would be a series of steps to produce or outcome / end in the form of controller a character or the how the game can be played and being able to play it at some level, but a good game would have multiple questions and a hard difficulty maybe even a customizable section for your character or object. In other words a Video game would be a series of steps to produce a outcome from controlling a character and a Good video game would be the same but added a level of difficulty and harder mechanics into the game.

Explanation:

Hope this helped :)

3 0
2 years ago
Where can the Ease of Access and Speech Recognition centers be found?
Bess [88]

Answer:

bottom right

Explanation:

at least on windows it's bottom right

3 0
3 years ago
Read 2 more answers
When you are saving a file, what does word suggest by default as the name of the document?
LenaWriter [7]
Whatever you have written on the page is what it'll name it.
5 0
3 years ago
Read 2 more answers
Create a function, return type: char parameters: int *, int * Inside the function, ask for two integers. Set the user responses
iris [78.8K]

Answer and Explanation:

In C programming language:

char fun(int*a, int*b){

printf("enter two integers: ");

scanf("%d%d",a,b);

int e;

printf("please enter a character: ");

e=getchar();

return e;

}

int main(int argc, char *argv[]) {

int d;

int f;

int g;

fun();

printf("%d%d%d", d, f, g);

}

We have declared a function fun type char above and called it in main. Note how he use the getchar function in c which reads the next available character(after the user inputs with printf()) and returns it as an integer. We then return the variable e holding the integer value as char fun() return value.

4 0
3 years ago
Other questions:
  • Assume that name has been declared suitably for storing names (like "amy" , "fritz" and "moustafa") write some code that reads a
    5·1 answer
  • What character separates the file extension and the filename?
    13·2 answers
  • When choosing a new computer to buy, you need to be aware of what operating _____ a0 it uses.
    6·1 answer
  • Ar count = 10;
    13·1 answer
  • epic poem - long narrative poem about heroic deeds about pharrell williams of the happy song please help i need the right answer
    11·1 answer
  • Discuss anomaly detection.
    5·1 answer
  • 2.36 LAB: Warm up: Variables, input, and casting (1) Prompt the user to input an integer, a double, a character, and a string, s
    12·1 answer
  • Worth 30 pts
    9·2 answers
  • Hewo want to talk! #bored<br>Will randomly mark brainlest
    12·1 answer
  • Which of the following is the key business objective behind the technologies implemented by PCL Construction, as discussed in th
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!