forked from Mooophy/Cpp-Primer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex14.43.cpp
50 lines (38 loc) · 960 Bytes
/
ex14.43.cpp
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
/***************************************************************************
* @file main.cpp
* @author Alan.W
* @date 20 Jan 2014
* @remark This code is for the exercises from C++ Primer 5th Edition
* @note
***************************************************************************/
//!
//! Exercise 14.43:
//! Using library function objects, determine whether a given int value is
//! divisible by any element in a container of ints.
//!
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <stack>
int main()
{
std::vector<int> v = {5,7,8,9};
std::modulus<int> mod;
int num;
while(std::cin >> num)
{
std::string ret = "no\n";
for (auto i : v)
{
if (! mod(num,i))
{
ret = "yes!\n";
break;
}
}
std::cout << ret;
}
return 0;
}