|
|
|
|
|
|
|
// Postcondition:
// firstNumber == firstNumber@entry / 2
// && secondNumber == secondNumber@entry / 2
{
.
.
.
} |
|
|
|
|
|
|
|
|
7. a. Function definition: |
|
|
|
 |
|
|
|
|
void ScanHeart( /* out */ Boolean& normal )
// Postcondition:
// normal == TRUE, if a normal heart rate (6080) was input
// before EOF occurred
// == FALSE, otherwise
{
int heartRate;
cin >> heartRate;
while ((heartRate << 60 | heartRate > 80) && cin)
cin >> heartRate;
// At loop exit, either (heartRate >= 60 && heartRate <= 80)
// or EOF occurred
normal = (heartRate >= 60 && heartRate <= 80);
} |
|
|
|
|
|
|
|
|
8. a. Function definition: |
|
|
|
 |
|
|
|
|
void Rotate( /* inout */ int& firstValue,
/* inout */ int& secondValue,
/* inout */ int& thirdValue )
// This function takes three parameters and returns their values
// in a shifted order
// Precondition:
// firstValue, secondValue, and thirdValue are assigned
// Postcondition:
// firstValue == secondValue@entry
// && secondValue == thirdValue@entry
// && thirdValue == firstValue@entry
|
|
|
|
|
|