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
sattari [20]
3 years ago
15

Find the Nearest Repeated Entries in an Array People do not like reading text in which a word is used multiple times in a short

paragraph. You are to write a program which helps identify such a problem. Write a program that takes as input an array and finds the distance between closest pairs of equal entries. For example if s = <"All, "work", "and", "no", "play", "makes", "for", "no", "work", "and", "no", "fun", "and", "no", "results">, then the second and third occurrences of "no" is the closest pair.
Computers and Technology
1 answer:
e-lub [12.9K]3 years ago
3 0

Answer:

The following program is written in C++ Programming Language.

#include <iostream>   //header file

#include<cstring>    //header file

using namespace std;   //using namespace

int main()    //main function

{

int num;

cout<<"Enter the no. of words: ";   //print message

cin>>num;    //get input from the user

char input[num][10];

int visited[num]={0};

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

{

cin>>input[i];

}

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

{

int distance=1000,left,right,prev,flag;

left=i;

prev=i;

if(visited[i]==0)

{

flag=0;

for(int j=i+1;j<num;j++)

{

if(strcmp(input[j],input[i])==0)

{

if(j-prev<distance)

{

left=prev;

right=j;

distance=j-prev;

}

prev=j;

visited[j]=1;

flag=1;

}

}

if(flag==1)

cout<<"The closest distance between the pair of "<<input[i]<<" is "<<distance<<" and pair is ("<<left<<" , "<<right<<")"<<endl;

}

}

return 0;

}

Explanation:

Here, we define two header file <iostream> and <cstring> and using namespace "std".

Then, we define the main() function.

Then, we declare an integer variable "num"  in which we get the input from the user.

Then, we initialized the two array variable first is character array "input" and integer array visited and after all, we follow the instructions.

You might be interested in
NEEEEEEEEEEEEEEEEEEEEEEEEEEED HELP PLZ HURRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
AveGali [126]

Answer:

The first step after selecting the File tab is to select <u>New</u>

Explanation:

Invoice templates are used in order to streamline the billing in business.

In order to use such templates by fetching them online such as from Office.com following steps should be followed:

  • Start the Microsoft Word software.
  • Click on File tab.
  • From the drop down memory choose New.
  • In the Search menu type Invoices and it will display all available templates of Invoices.
  • On the homepage, their will be be an option for More Templates below the available ones. Click on it and choose the Category from left and click Invoices.
  • Select the template you want to use.

<h3>I hope it will help you!</h3>
7 0
4 years ago
What term is commonly used to refer to HTML formatting?
yanalaym [24]

Answer: No particular term

Explanation:

If by formatting you are referring to the presentation of the html page or website means how the forntend looks then css is used. In case of text formatting then bold <b><b/> italic <i></i> small <small></small> superscript <sup></sup> subscript <sub></sub> etc tags available

6 0
4 years ago
explain the importance of computer to you, in various academic fields in business, personnel officer,procurement and so on​
fiasKO [112]

Explanation:

Computers have become essential business tools. They are used in every aspect of a company's operations, including product creation, marketing, accounting and administration. It is critical that business owners take the time to choose the right computers, software and peripherals for their organization. Given the diversity of modern technology, from smartphones and tablets to large desktop systems, the choice of the best tech for your business can be daunting.

8 0
3 years ago
Read 2 more answers
A microcomputer that is smaller, lighter, and less powerful than a notebook, and which has a touch sensitive screen, is called a
bekas [8.4K]

I guess the answer in the blank is Tablet.

A microcomputer that is smaller, lighter, and less powerful than a notebook, and which has a touch sensitive screen, is called a tablet.

7 0
3 years ago
Egyptian hieroglyphs were part of a writing system used by the ancient Egyptians. What type of graphic design elements did they
Lina20 [59]

Answer:

Logographic, syllabic, and alphabetic elements. I think thts what u were asking for?

Explanation:

3 0
4 years ago
Other questions:
  • How do air and ocean currents affect climate
    5·2 answers
  • Which spreadsheet operation does a look function perform?
    5·1 answer
  • Which option should u select to ignore all tracked changes in a document
    8·1 answer
  • What are two best practices for discovering whether a message you’ve scheduled with Hootsuite has failed to send?
    8·2 answers
  • What is one reason that writing effective messages is so important
    11·2 answers
  • I NEED HELP ASAP IM BAD AT THIS
    10·1 answer
  • Opposite word of reassembling​
    15·2 answers
  • Cui documents must be reviewed to which procedures before destruction?
    13·1 answer
  • What is the accurate description
    12·1 answer
  • List and describe the five moral dimensions that are involved in political, social, and ethical issues. Which do you think will
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!