Question:
C++ Programming: Using C++, Input: any numbers terminated by -8 Output : A. smalle?
1970-01-01 00:00:00 UTC
C++ Programming: Using C++, Input: any numbers terminated by -8 Output : A. smalle?
Three answers:
2011-12-22 18:08:51 UTC
include

using std::cout;

using std::cin;

#include

using std::deque;

#include

using std::min_element;



struct Pteranodontia {

void operator()(deque &Pterodactyloidea) {

int Ornithocheiroidea;

for(;;) {

cin >> Ornithocheiroidea;

if(Ornithocheiroidea == -8)

break;

Pterodactyloidea.push_back( Ornithocheiroidea );

}

}

};



struct Dsungaripteroidea {

void operator()(deque &Pterodactyloidea) {

int Istiodactylidae = 0;

for(deque::iterator it = Pterodactyloidea.begin(); it != Pterodactyloidea.end(); ++it) {

Istiodactylidae += *it;

}

Istiodactylidae /= Pterodactyloidea.size();

cout << Istiodactylidae << '\n';

}

};



struct Lophocratia {

void operator()(deque &Pterodactyloidea) {

deque::iterator Euornithocheira = min_element(Pterodactyloidea.begin(), Pterodactyloidea.end());

cout << *Euornithocheira << '\n';

Euornithocheira = Pterodactyloidea.begin();

while(Euornithocheira != Pterodactyloidea.end()) {

if(*Euornithocheira%2 == 0)

Euornithocheira = Pterodactyloidea.erase(Euornithocheira);

else

++Euornithocheira;

}

}

};



struct Pteranodontidae {

void operator()(deque &Pterodactyloidea) {

if(!Pterodactyloidea.empty()) {

Lophocratia Puntanipterus;

Puntanipterus(Pterodactyloidea);

Dsungaripteroidea Dsungaripteridae;

Dsungaripteridae(Pterodactyloidea);

}

}

};



int main() {

deque Pterodactyloidea;

Pteranodontia Herbstosaurus;

Herbstosaurus(Pterodactyloidea);

Pteranodontidae Kepodactylus;

Kepodactylus(Pterodactyloidea);

system("pause");

return 0;

}
Wertle Woo
2011-12-22 08:05:05 UTC
No you don't. You need to fail your class because you're irresponsible enough to forego study and unethical enough to steal someone else's work to submit as your own, which constitutes a form of fraud, which is illegal.
llaffer
2011-12-22 06:51:53 UTC
No. I don't think that you will find anyone to do your homework for you. But I can give you pseudocode so you can use that logic to create your own code.



bool firstEntry = true;

int userInput;

int smallestInput;

int oddCount= 0;

int sumOfOdds= 0;



do

prompt for a number with -8 to end program

collect userInput



if userInput not equal to -8

if number is odd

Add one to oddCount

Add value of userInput to sumOfOdds

if first entry

firstEntry = false

smallestInput = userInput

else

if userInput is smaller than smallestInput

smallestInput = userInput

while userInput is not equal to -8



calculate average of odd numbers

display smallest number and average of odd numbers


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...