I'm a first year programmer and Im just learning the basics...I have this program so far but all it does is take 20 numbers and print them out I need to figure out how to take the input and print them out with no repeats...any ideas??
Heres the program:
1. Accountant. Write a program that accepts a sequence of integers (some of which may repeat) as input
and prints every integer exactly once. You can assume that there are no more than 20 integers in the input.
But there may be less. Zero signifies the end of input. It should NOT be printed.
For example, when the following input is provided to your program:
5 6 22 5 22 7 6 0
your program should print:
5 6 22 7
heres what i got:
#include <iostream>
using namespace std;
int main()
{
int array[20];
int x =0;
for(int x=0; x<20; x++)
cin>>array[x];
for(x=0; x<20; x++)
cout << array[x] << endl;
return 0;
}
Heres the program:
1. Accountant. Write a program that accepts a sequence of integers (some of which may repeat) as input
and prints every integer exactly once. You can assume that there are no more than 20 integers in the input.
But there may be less. Zero signifies the end of input. It should NOT be printed.
For example, when the following input is provided to your program:
5 6 22 5 22 7 6 0
your program should print:
5 6 22 7
heres what i got:
#include <iostream>
using namespace std;
int main()
{
int array[20];
int x =0;
for(int x=0; x<20; x++)
cin>>array[x];
for(x=0; x<20; x++)
cout << array[x] << endl;
return 0;
}
Comment