1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <iostream>
template < typename T > bool unique(T) { return true ; }
template < typename A, typename B, typename... R > bool unique( A a, B b, R... r )
{
if( sizeof...(R) == 0 ) return a != b ;
else return a != b && unique( a, r... ) && unique( b, r... ) ;
}
int main()
{
int a, b, c, d, e, f, g, h, i, j, k, m, n, p, q ;
std::cout << "enter 15 integers\n" ;
std::cin >> a >> b >> c >> d >> e >> f >> g >> h >> i >> j >> k >> m >> n >> p >> q ;
const bool result = unique( a, b, c, d, e, f, g, h, i, j, k, m, n, p, q ) ;
std::cout << "\nare these 15 unique numbers? " << ( result ? "yes\n" : "no\n" ) ;
}
|