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
sleet_krkn [62]
3 years ago
15

Write a program that reads in non-negative integers and stores and displays distinct numbers (i.e., if a number appears multiple

times, it is stored and displayed only once). Your program should allow up to 1000 distinct numbers to be stored and displayed. Use the following algorithm (this is required!): Read each number and store it in an array if it is new. If the number is already in the array, ignore it. The user will indicate that they are done entering numbers by entering a negative number. Here is a sample run:
Enter a non-negative integer (negative to quit): 1
Enter a non-negative integer (negative to quit): 2
Enter a non-negative integer (negative to quit): 3
Enter a non-negative integer (negative to quit): 2
Enter a non-negative integer (negative to quit): 1
Enter a non-negative integer (negative to quit): 6
Enter a non-negative integer (negative to quit): 3
Enter a non-negative integer (negative to quit): 4
Enter a non-negative integer (negative to quit): 5
Enter a non-negative integer (negative to quit): 2
Enter a non-negative integer (negative to quit): -4
You entered:
1 2 3 6 4 5
Computers and Technology
1 answer:
slavikrds [6]3 years ago
4 0

Answer:

See explaination

Explanation:

#include <iostream>

using namespace std;

#define MAX 1005

bool already_present(int data[MAX], int input, int size)

{

int i;

for(i=0;i<size;i++)

if(data[i] == input)

return true;

return false;

}

int read_stdin(int data[MAX])

{

int input;

int size=0;

while(true)

{

cout<<"Enter a non-negative integer (negative to quit): ";

cin>>input;

if(input<0)

break;

if(!already_present(data,input,size))

data[size++] = input;

}

return size;

}

void print_stdout(int data[MAX],int size)

{

int i;

cout<<"You entered\n";

for(i=0;i<size;i++)

cout<<data[i]<<" ";

cout<<endl;

}

int main()

{

int data[MAX],size;

size = read_stdin(data);

print_stdout(data,size);

return 1;

}

You might be interested in
An installation is:<br> please help asap
pogonyaev

Answer:  an installation is the act of putting something in, a device that stays in one place, a military base, or an art piece that often involves building and different types of materials.

Explanation:

Getting your new air conditioner put in is an example of an installation.

4 0
3 years ago
Describe software as a service. what features distinguish it from application software installed on a personal computing device
Triss [41]
???????????????????????????
6 0
3 years ago
Read 2 more answers
6. The following is a dump of a DATA chunk in hexadecimal format. 00000015 00000005 0003000A 00000000 48656C6C 6F000000 a. Is th
ryzh [129]

Answer:

Explanation:

a) taking 00000005, it is a 13th bit which is 0, and therefore, we'd call it an ordered chunk

b) taking 00000005 again, it is 14th (B) and 15th (E) bits are 0 and so we'd call it a middle fragment

c) 00000015 is equal to 21, it is not a multiple of 4, and as such, it needs 3 padding bytes

d) 00000005 is equal to 5 making it a TSN. So the TSN is 5

e) taking 0003, we can then say the SI is 3

f) taking 000A, the SSN is then 10

g) the message is 48656C6C

6 0
2 years ago
In a relational database, the three basic operations used to develop useful sets of data are:
lesya692 [45]
<span>Which is not a component of a database that describes how data is stored?</span>
6 0
3 years ago
The picture that graphically represents the items you use in Windows is called a/an
Fofino [41]
Icon need to use 20  characters <span />
7 0
3 years ago
Other questions:
  • An outline is most like which of the following?
    7·1 answer
  • ________ is used for supervisory messages at the internet protocol layer.
    10·1 answer
  • A type of multiprocessor chip that provides two or more separate and independent CPUs.
    8·1 answer
  • Science Help
    11·1 answer
  • Determine the following information about each value in a list of positive integers.
    14·1 answer
  • Users who are connecting to an NLB cluster have been complaining that after using the site for a few minutes they are prompted t
    15·1 answer
  • क) मानौं तिमी बसेको समाजमा मान्छेहरूले सधै फोहर फाल्ने गर्नाले वातावरण प्रदूषित
    13·1 answer
  • Write a function solution that, given an array A consisting of N integers, returns the number of fragements of A whose sum equal
    9·1 answer
  • Complete the sentence.<br> Python is a_____<br> level language compared to bytecode.
    7·2 answers
  • Do you know the energy unit question?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!