Computers and Technology

Run the program and observe the output to be: 55 4 250 19. Modify the numsInsert function to insert each item in sorted order. The new program should output: 4 19 55 250. #include
#include
using namespace std;
void numsInsert(vector& numsList, int newNum) {
unsigned int i;
for (i = 0; i < numsList. size(); ++i) {
if (newNum < numsList. at(i)) {
// FIXME: insert newNum at element i
break; // Exits the for loop
}
}
// FIXME: change so executes if higher number NOT found
// Change "true" to "i == ??" (determine what ?? should be)
if (true) { // No higher number was found, so append to end
numsList. push_back(newNum);
}
}
void numsPrint(const vector& numsList) {
unsigned int i;
for (i = 0; i < numsList. size(); ++i) {
cout << " " << numsList. at(i) << endl;
}
}

int main() {
vector numsList;
numsInsert(numsList, 55);
numsInsert(numsList, 4);
numsInsert(numsList, 250);
numsInsert(numsList, 19);
numsPrint (numsList);

return 0;
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 18:20, LuchaPug
Write the pseudocode for the following: a function called fahrenheittocelsius that accepts a real fahrenheit temperature, performs the conversion, and returns the real celsius temperature. a function called celsiustofahrenheit that accepts a real celsius temperature, performs the conversion, and returns the real fahrenheit temperature. a main module that asks user to enter a fahrenheit temperature, calls the fahrenheittocelsius function, and displays the celsius temperature with a user-friendly message. it then asks the user to enter a celsius temperature, calls the celsiustofahrenheit function, and displays the fahrenheit temperature with a user-friendly message.
Answers: 1
image
Computers and Technology, 22.06.2019 18:30, Akkenson17871
The "instance" relationship shows that something is an object of a
Answers: 1
image
Computers and Technology, 24.06.2019 10:00, genyjoannerubiera
In which view can you see speaker notes?
Answers: 1
image
Computers and Technology, 24.06.2019 15:30, taylorpayne525p8qxky
What is not a type of text format that will automatically be converted by outlook into a hyperlink?
Answers: 1
Do you know the correct answer?
Run the program and observe the output to be: 55 4 250 19. Modify the numsInsert function to insert...

Questions in other subjects:

Konu
Computers and Technology, 26.07.2019 18:00