August 2002
Beginner
1122 pages
22h 1m
English
Let's take our program modification one step at a time, starting with just the top two weights. Figure 4.1 is one possible way to handle this version of the problem.
#include <iostream>
using namespace std;
int main()
{
short CurrentWeight;
short HighestWeight;
short SecondHighestWeight;
cout << "Please enter the first weight: ";
cin >> CurrentWeight;
HighestWeight = CurrentWeight;
SecondHighestWeight = 0;
cout << "Current weight " << CurrentWeight << endl;
cout << "Highest weight " << HighestWeight << endl;
while (CurrentWeight > 0)
{
cout << "Please enter the next weight: ";
cin >> CurrentWeight;
if (CurrentWeight > HighestWeight)
{
SecondHighestWeight ... |
Read now
Unlock full access