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
tester [92]
3 years ago
11

Write a program that will filter a list of non-negative integers such that all duplicate values are removed. Integer values will

come from standard input (the keyboard) and will range in value from 0 up to 2,000,000,000. Input will be terminated by the special value, -1. Once the input is read in you should output (to the screen) the list of numbers as a sorted list (smallest to largest) with one value listed per line where all duplicates have been removed. The primary difficulty with this program is that there are an enormous number of input values and an expected large number of duplicate numbers.
Computers and Technology
1 answer:
Mrrafil [7]3 years ago
4 0

Answer:

The program in python is as follows:

original = []

inp = int(input(": "))

while inp>=0:

   if inp<=2000000000:

       original.append(inp)

   inp = int(input(": "))

newlist = []

for i in original:

if i not in newlist:

 newlist.append(i)

newlist.sort()

for i in newlist:

   print(i)

Explanation:

This initializes the original list

original = []

This gets input for the list

inp = int(input(": "))

The following loop is repeated while input is not negative

while inp>=0:

This ensures that only inputs from 0 and 2000000000 enters the list

<em>    if inp<=2000000000: </em>

<em>        original.append(inp) </em>

Prompt the user for another input

   inp = int(input(": "))

This initializes a newlist

newlist = []

Iterates through the original list

for i in original:

Check for duplicate

if i not in newlist:

Each number is entered to the new list, without duplicate

 newlist.append(i)

This sorts the new list in ascending order

newlist.sort()

This prints the list item one per line

<em>for i in newlist: </em>

<em>    print(i)</em>

You might be interested in
In GamePoints' constructor, assign teamWhales with 500 and teamLions with 500. #include using namespace std; class GamePoints {
xxMikexx [17]

Answer:

Here is the GamePoints constructor:

GamePoints::GamePoints() :

/* Your code goes here */

{

teamLions = 500;

teamDolphins = 500;

}    

Explanation:

Here is the complete program:

#include  //to use input output functions

using namespace std; //to identify objects like cin cout

class GamePoints {  //class GamePoints

   public: GamePoints(); // constructor of GamePoints class

   void Start() const;  //method of GamePoints class

   private: //declare data members of GamePoints class

   int teamDolphins; // integer type private member variable of GamePoints

   int teamLions; }; // integer type private member variable of GamePoints

   GamePoints::GamePoints()  //constructor

    { teamLions = (500), teamDolphins= (500); }   //assigns 500 to the data members of teamLions  and teamDolphins of GamePoints class

   void GamePoints::Start() const    { //method Start of classs GamePoints

       cout << "Game started: Dolphins " << teamDolphins << " - " << teamLions << " Lions" << endl; }  //displays the values of teamDolphins and teamLions i.e. 500 assigned by the constructor

       int main() //start of main() function

       { GamePoints myGame;  // creates an object of GamePoints class

       myGame.Start(); //calls Start method of GamePoints class using the object

       return 0; }

The output of the program is:

Game started: Dolphins 500 - 500 Lions                    

8 0
3 years ago
Write an algorithm to find the area of a circle of radius r
Bas_tet [7]

Answer:

e=mc^2

Explanation:

4 0
2 years ago
A function may return a pointer, but the programmer must ensure that the pointer:
elena-14-01-66 [18.8K]
Hello i am kust gere to answer the qustions nothing else
4 0
4 years ago
Each TextField has a text property that's returned by its textProperty method as a StringProperty. The StringProperty method ___
masha68 [24]

Answer:

B: Bind

Explanation:

JavaFX property binding permits the synchronization of the value of two properties in such a way that whenever there is a change in one of the properties, there is an immediate update on the value of the other property. In this way, The StringProperty method bind receives an ObservableValue as an argument. When the ObservableValue changes, the bound property is updated accordingly.

4 0
3 years ago
c) Do hardware purchases or salaries for IT workers demand a greater share of the total cost of the ownership of the IT infrastr
atroni [7]

Answer:Yes, with increase in the need for IT, and the constant improvements in IT, there is a need to recruit Qualified IT professionals who are knowledgeable.

With new technologies developing with a fast pace,there will be a constant need to invest in IT hardwares in order to meet with the increasing challenges.

Explanation:IT(Information technology) is a term used to describe the processes through Information is sent from one point to another through one or more media.

The field of Information technology is constantly evolving with several improvements taking place around the globe, Medium sized companies will need to constantly make expenditures on both the IT infrastructures and the IT professionals both as permanent employees or as contracted experts.

6 0
4 years ago
Read 2 more answers
Other questions:
  • TCP has a 32-bit sequence number field and 16-bit advertised window field. Assume that RTT is 512 (2 9 ) ms, transmission speed
    6·1 answer
  • In the 219th meeting of the American Astronomical Society, what planet's borders were said to be recognizable from space? Hint:
    12·1 answer
  • Professional photography is a competitive job field. <br> true <br> false
    12·2 answers
  • A spreadsheet can be filtered only by one column at a time? <br> true or false
    14·2 answers
  • Assume that the type NAME has already been defined. Define a new type, SREC that is a structure consisting of two fields: name (
    5·1 answer
  • Complete the statement pertaining to the number of frames used by the national television system committee. The national televis
    9·1 answer
  • The Internet:
    12·1 answer
  • What does an arrow after a command indicate
    13·2 answers
  • ____ loses data when it stops receiving electrical power.
    10·1 answer
  • Select 3 true statements about Python class.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!