Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need my program to do this when inputted a sentence: input: \"you you are are

ID: 3530895 • Letter: I

Question

I need my program to do this when inputted a sentence:


input:


"you you are are a happy person lol"


output:


you 2

are 2

a 1

happy 1

person 1

lol 1


for now I have this: https://docs.google.com/document/d/1hsmSvUStgvj_bZ9UbJEycyCIxJQAoH0H9zxJuXmJCjo/edit


I am new to strings and I am just stuck... How do I check the frequency of repeating words? Also, and I feel terrible for asking this, please give me a coded solution for this. My goal is to learn by myself, but a reference would definitely help. I don't know how I can prove to you that I won't turn in your program... may be send you the program I wrote myself?


If that is to much to ask, please give detailed instructions to the code for this program. Thanks in advance.

Explanation / Answer

//something like this:


#include <iostream>

#include <cstdlib>

#include <cstring>

using namespace std;


const int MAX = 80;

void ShowTwoD(char table[][MAX+1], int count,int counts[]);

void Insert(char table[][MAX+1], char insertThis[], int &count,int counts[]);


int main()

{

int count = 0;

int counts[MAX]={0};


char word[MAX+1];

char table[20][MAX+1];


cout<<"Input words: ";


do{

cin>>word;

Insert(table, word, count,counts);

}while(cin.get()!=' ');


ShowTwoD(table, count,counts);

return 0;


}


void ShowTwoD(char table[][MAX+1], int count,int counts[])

{

cout<<endl<<"ShowTwoD: count="<< count<<endl;

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

{

cout<<table[i]<<" "<<counts[i]<<endl;

}

}


void Insert(char table[][MAX+1], char insertThis[], int &count, int counts[])

{

int index=-1;

for(int i=0;i<count;i++){

if(strcmp(table[i],insertThis)==0){ //if equal

index=i;

break; //exit for loop since there should only be 1 copy of word

}

}

if(index==-1){ //not found

strcpy(table[count], insertThis);

counts[count]=1;

count++;

}

else

counts[index]++;


}