#include using namespace std; void deleteRepeats (char[], int&); int main() { char alpha[10]; alpha[0]= 'n'; alpha[1] = 't'; alpha[2] = 't'; alpha[3]= 'a'; alpha[4] 'd'; alpha [5] = 'n'; alpha[6] = 'c'; alpha[7] = 'c'; alpha[8] = 'a'; Copy the main code and complete delete Repeats function int size= 9; deleteRepeats (alpha, size); cout << "After deleting repeat" << endl; for (int i = 0; i < size; ++i) cout << alpha[i] << endl; return 0;
Use C++
code-
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
void deleteRepeats(char alpha[],int size){
int k=0;char alpha2[10];int j=0;int i=0;
for ( i = 0; i < size; i++)
{
for ( j = 0; j < k; j++)
{
if (alpha[i] == alpha2[j])
break;
}
if (j == k)
{
alpha2[k] = alpha[i];
k++;
}
}
cout << "After deletion repeat "<<endl;
for (i = 0; i < k; i++)
{ cout << alpha2[i] << endl;}
}
int main()
{
char alpha[10];
alpha[0]='m';
alpha[1]='t';
alpha[2]='t';
alpha[3]='a';
alpha[4]='d';
alpha[5]='m';
alpha[6]='c';
alpha[7]='c';
alpha[8]='a';
int size=9;
deleteRepeats(alpha,size);
}
Step by step
Solved in 2 steps with 1 images