1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#include <iostream>
#include <string>
#include <algorithm>
template<typename T>
const T& min(const T& obj1)
{
return obj1;
}
template<typename T, typename... Types>
const T& min(const T& person1, const T& person2, Types... people)
{
const T& min_person = std::min(person1, person2);
return min(min_person, people...);
}
int main() {
int Person1;
int Person2;
int Person3;
int Person4;
int Person5;
int Person6;
int Person7;
int Person8;
int Person9;
int Person10;
std::cout << "How many pancakes has each Person had?\n\n";
std::cout << "Person 1: ";
std::cin >> Person1;
std::cout << "Person 2: ";
std::cin >> Person2;
std::cout << "Person 3: ";
std::cin >> Person3;
std::cout << "Person 4: ";
std::cin >> Person4;
std::cout << "Person 5: ";
std::cin >> Person5;
std::cout << "Person 6: ";
std::cin >> Person6;
std::cout << "Person 7: ";
std::cin >> Person7;
std::cout << "Person 8: ";
std::cin >> Person8;
std::cout << "Person 9: ";
std::cin >> Person9;
std::cout << "Person 10: ";
std::cin >> Person10;
const int& PersonMin = min(
Person1, Person2, Person3,
Person4, Person5, Person6,
Person7, Person8, Person9,
Person10
);
std::cout << "min = " << PersonMin << '\n';
}
|