Write a function called delete_repeats that has a partially filledarray of chara
ID: 3561829 • Letter: W
Question
Write a function called delete_repeats that has a partially filledarray of characters as a formal parameter and that deletes allrepeated letters from the array. Since a partially filled arrayrequires two arguments, the function will actually have two formalparameters: an array parameter and a formal parameter of typeint that gives the number of array positions used. When aletter is deleted, the remaining letters are moved forward to fillin the gap. This will create empty positions at the end of thearray so that less of the array is used. Since the formal parameteris a partially filled array, a second formal parameter of typeint will tell how many array positions are filled. Thissecond formal parameter will be a call-by-references parameter andwill be changed to show how much of the array is used after therepeated letters are deleted.
Explanation / Answer
This is only the function not the entire code.
#include<bits/stdc++.h>
using namespace std;
vector<int >iterator::it;
void delete_repeats(vector<int> arr,int size, int& vsize){
sort(arr.begin(),arr.end()); /*Assuming you know STL*/
for(it=arr.begin();;){
if(arr[it+1]=arr[it]){
arr.erase(it+1);
vsize--;
}
else it++;
}
}
int main(){
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.