C++
x
23
1
2
3
4
5
struct Ship {
6
bool d;
7
Ship(bool dd = false) : d(dd){}
8
bool isDestroyed() const;
9
};
10
11
bool Ship::isDestroyed() const
12
{
13
return d;
14
}
15
16
int main(){
17
std::vector<Ship> ships = {true, true, true, true, true, false, true, true, true, true};
18
bool destroyed = std::all_of(ships.begin(), ships.end(),
19
[](const Ship& ship){ return ship.isDestroyed(); });
20
std::cout << std::boolalpha << destroyed << std::endl;
21
return 0;
22
}
23
$ g++ prog.cc -Wall -Wextra -std=c++11 -pedantic
Start
false
0
Finish