Please look at the problems I amhavingwhichare listed below:
Write a programthat inputs 10 integers fromthe user into anarray, and removes the duplicate arrayelements. Byremoving, I meant that you
should make it appear as ifthe elements hadn't beenthere. So not just settingduplicates to an"empty"value, but fillinginthe gap. That means
movingallthe later elements back one (kind oflike whenyouhit backspace inthe middle ofa line ina text editor). Or alternatively, storingonlythe
non-repeatingelements. Youmayassume that allthe integers are between0 and 100, Write at least 1 functioninadditionto the mainfunction, and
pass anarrayinto that functionas a parameter.
Output should look exactlylike below. Two rows.
ProgramInput:
0 1 2 3 4 5 6 7 8 9
ProgramOutput:
Please enter 10 integers, hittingreturnafter eachone:n
0 1 2 3 4 5 6 7 8 9
ProgramInput:
100 100 100 100 100 100 100 100 100 100 100
ProgramOutput:
Please enter 10 integers, hittingreturnafter eachone:n
100
ProgramInput:
11 11 22 22 33 33 44 44 55 55
ProgramOutput:
Please enter 10 integers, hittingreturnafter eachone:n
11 22 33 44 55
ProgramInput:
12 37 12 37 45 88 101 21 21 101
ProgramOutput:
Please enter 10 integers, hittingreturnafter eachone:n
12 37 45 88 101 21
I have:
#include<iostream>
usingnamespace std;
void eliminate(int a[], int&siz)
{
int i,n=0;
boolb[101]={false};
for(i=0;i<siz;i++)
b[a[i]]=true;
for(i=0;i<101;i++)
if(b[i]) a[n++]=i;
siz=n;
}
int main()
{
int nums[10];
int i,n=10;
cout<<"Please enter 10 integers, hittingreturnafter eachone:n";
for(i=0;i<n;i++)
cin>>nums[i];
eliminate(nums,n);
cout<<endl;
for(i=0;i<n;i++)
cout<<nums[i]<<"";
return0;
}
--- PROBLEMS I AM HAVING---
1) After, cout<<"Please enter 10 integers, hittingreturnafter eachone:n"; I receive 2 "/n"howdo I onlyreceive one "n"after the colon.
2) For mylast output, I receive 12 12 21 37 45 88 whenI should be receiving12 37 45 88 101 21

Please look at the problems I am having which are listed below: Write a program that inputs 10 inte

  • 1.
    Please look atthe problems I amhavingwhichare listed below: Write a programthat inputs 10 integers fromthe user into anarray, and removes the duplicate arrayelements. Byremoving, I meant that you should make it appear as ifthe elements hadn't beenthere. So not just settingduplicates to an"empty"value, but fillinginthe gap. That means movingallthe later elements back one (kind oflike whenyouhit backspace inthe middle ofa line ina text editor). Or alternatively, storingonlythe non-repeatingelements. Youmayassume that allthe integers are between0 and 100, Write at least 1 functioninadditionto the mainfunction, and pass anarrayinto that functionas a parameter. Output should look exactlylike below. Two rows. ProgramInput: 0 1 2 3 4 5 6 7 8 9 ProgramOutput: Please enter 10 integers, hittingreturnafter eachone:n 0 1 2 3 4 5 6 7 8 9 ProgramInput: 100 100 100 100 100 100 100 100 100 100 100 ProgramOutput: Please enter 10 integers, hittingreturnafter eachone:n 100 ProgramInput: 11 11 22 22 33 33 44 44 55 55 ProgramOutput: Please enter 10 integers, hittingreturnafter eachone:n 11 22 33 44 55 ProgramInput: 12 37 12 37 45 88 101 21 21 101 ProgramOutput: Please enter 10 integers, hittingreturnafter eachone:n 12 37 45 88 101 21 I have: #include<iostream> usingnamespace std; void eliminate(int a[], int&siz) { int i,n=0; boolb[101]={false}; for(i=0;i<siz;i++) b[a[i]]=true; for(i=0;i<101;i++) if(b[i]) a[n++]=i; siz=n; }
  • 2.
    int main() { int nums[10]; inti,n=10; cout<<"Please enter 10 integers, hittingreturnafter eachone:n"; for(i=0;i<n;i++) cin>>nums[i]; eliminate(nums,n); cout<<endl; for(i=0;i<n;i++) cout<<nums[i]<<""; return0; } --- PROBLEMS I AM HAVING--- 1) After, cout<<"Please enter 10 integers, hittingreturnafter eachone:n"; I receive 2 "/n"howdo I onlyreceive one "n"after the colon. 2) For mylast output, I receive 12 12 21 37 45 88 whenI should be receiving12 37 45 88 101 21