// Assignment Final Question 7
//
// Name: <Maribel Fuentes>
//
// Class: C Programming, <Fall 2024>
//
// Date: <December 2, 2024>
#include <iostream>
#include <algorithm> // For std::max and std::min
class NumberSet {
private:
int values[6];
public:
// Constructor to initialize the six values
NumberSet(int v1, int v2, int v3, int v4, int v5, int v6) {
values[0] = v1;
values[1] = v2;
values[2] = v3;
values[3] = v4;
values[4] = v5;
values[5] = v6;
}
// Member function to return the largest of the six values
int Largest() {
int largest = values[0];
for (int i = 1; i < 6; ++i) {
if (values[i] > largest) {
largest = values[i];
}
}
return largest;
}
// Member function to return the smallest of the six values
int Smallest() {
int smallest = values[0];
for (int i = 1; i < 6; ++i) {
if (values[i] < smallest) {
smallest = values[i];
}
}
return smallest;
}
};
int main() {
// Example usage
NumberSet numbers(10, 20, 5, 30, 25, 15);
std::cout << "Largest value: " << numbers.Largest() << std::endl;
std::cout << "Smallest value: " << numbers.Smallest() << std::endl;
return 0;
}
Ly8gQXNzaWdubWVudCBGaW5hbCBRdWVzdGlvbiA3Ci8vCi8vIE5hbWU6IDxNYXJpYmVsIEZ1ZW50ZXM+Ci8vCi8vIENsYXNzOiBDIFByb2dyYW1taW5nLCA8RmFsbCAyMDI0PgovLwovLyBEYXRlOiA8RGVjZW1iZXIgMiwgMjAyND4KCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGFsZ29yaXRobT4gLy8gRm9yIHN0ZDo6bWF4IGFuZCBzdGQ6Om1pbgoKY2xhc3MgTnVtYmVyU2V0IHsKcHJpdmF0ZToKICAgIGludCB2YWx1ZXNbNl07CgpwdWJsaWM6CiAgICAvLyBDb25zdHJ1Y3RvciB0byBpbml0aWFsaXplIHRoZSBzaXggdmFsdWVzCiAgICBOdW1iZXJTZXQoaW50IHYxLCBpbnQgdjIsIGludCB2MywgaW50IHY0LCBpbnQgdjUsIGludCB2NikgewogICAgICAgIHZhbHVlc1swXSA9IHYxOwogICAgICAgIHZhbHVlc1sxXSA9IHYyOwogICAgICAgIH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