// Assignment Question 7 Final Exam
//
// Name: <Tasos Paloukos>
//
// Class: C Programming, <Fall 2024>
//
// Date: <December 11, 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;
}
Ly8gQXNzaWdubWVudCBRdWVzdGlvbiA3IEZpbmFsIEV4YW0KLy8KLy8gTmFtZTogPFRhc29zIFBhbG91a29zPgovLwovLyBDbGFzczogQyBQcm9ncmFtbWluZywgPEZhbGwgMjAyND4KLy8KLy8gRGF0ZTogPERlY2VtYmVyIDExLCAyMDI0PgoKI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPiAvLyBGb3Igc3RkOjptYXggYW5kIHN0ZDo6bWluCgpjbGFzcyBOdW1iZXJTZXQgewpwcml2YXRlOgogICAgaW50IHZhbHVlc1s2XTsKCnB1YmxpYzoKICAgIC8vIENvbnN0cnVjdG9yIHRvIGluaXRpYWxpemUgdGhlIHNpeCB2YWx1ZXMKICAgIE51bWJlclNldChpbnQgdjEsIGludCB2MiwgaW50IHYzLCBpbnQgdjQsIGludCB2NSwgaW50IHY2KSB7CiAgICAgICAgdmFsdWVzWzBdID0gdjE7CiAgICAgICAgdmFsdWVzWzFdID0gdjI7CiAgICAgICAgdmFs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