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
You have to display or connect to network shares on remote computers. Which command-line utility will you use to accomplish the
Xelga [282]

Answer:

net use X: \\SERVER\Share

Explanation:

1. Connect securely to the remote computer or ensure you have access to it on the network

2. then follow the step below:

Where X: is the drive letter you wish to map the share to, and \\SERVER\Share is the UNC path to the share. This should make the share visible in My Computer and the command line as well like all other shares mapped through the GUI.

In order to later disconnect the share, you would use

net use X: /delete

8 0
3 years ago
Your co-worker is at a conference in another state. She requests that you
aniked [119]

Answer:

C

Explanation:

This is the easiest, quickest, and least destructive method.

3 0
3 years ago
Which technique/concept can be use toimplement multiple inheritances<br> in java?
LiRa [457]

Answer:

Interface

Explanation:

Java does not supports multiple inheritance by class, but we can implement multiple inharitacnce in  java using interface, with interface we uses implements keyword.

Example-

Declare interface like below code -

interface parent{

}

and use in child class like below code -

class Child1 implements interface{

}

class Child2 implements interface{

}

8 0
3 years ago
Social engineering attacks can be carried out:______.
Alik [6]
The answer most likely B NOT SURE )
3 0
3 years ago
Help me please I dont have enough points for people just to get these for free
Gekata [30.6K]

Answer:

help me please I dont have enough points for people just to get these for free

Sam is a movie director. He has asked his storyboard artist to create an image of the central character looking ecstatic after receiving an award. What type of shot does the director need from the storyboard artist?

A. long shot

B. point of view shot

C. reaction shot

D. jump cut​

A is the asnwer

3 0
2 years ago
Other questions:
  • Which type of network cover a large geographical area and usually consists of several smaller networks, which might use differen
    5·1 answer
  • what aspect should you consider before adding pictures to a document? you should structure the first before you search for a rel
    15·2 answers
  • How can a user preview the playback of an audio clip in PowerPoint? Use the drop-down menus to complete the statements.
    14·1 answer
  • What will be the values of ans, x, and y after the following statements are executed? int ans = 35, x = 50, y =50; if ( x &gt;=
    7·2 answers
  • The linear programming ingredient or blending problem model allows one to include not only the cost of the resource, but also th
    14·1 answer
  • Which letter would appear in the third position of the standard wheel marking of a hard-grade wheel?
    10·2 answers
  • Add the following method to the Point class: public double distance(Point other) Returns the distance between the current Point
    12·1 answer
  • The __________ gear is the input gear.<br> A. Drive<br> B. Driven
    5·2 answers
  • Write if true or false
    12·1 answer
  • The people on this platform are unbelievably nice. its almost rare to see this type of kindness online these days. Just wanted t
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!