fork download
  1. #include <bits/stdc++.h>
  2. // I didn't check for Null. Null is just a zero in c/c++, and zero is false
  3.  
  4. using namespace std;
  5.  
  6. unsigned int sheeps_sum(vector<bool>& sheeps);
  7.  
  8. int main(){
  9. vector<bool> test = { true, true, true, false,
  10. true, true, true, true,
  11. true, false, true, false,
  12. true, false, false, true,
  13. true, true, true, true,
  14. false, false, true, true };
  15.  
  16. cout << sheeps_sum(test) << endl;
  17. return 0;
  18. }
  19.  
  20. unsigned int sheeps_sum(vector<bool>& sheeps){
  21. return accumulate(sheeps.begin(), sheeps.end(), 0ULL);
  22. }
  23.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
17