fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main() {
  6. int a[] = {1,3,0,5,2,-2,5,0,4,3,0};
  7. cout << count_if(begin(a),end(a),[](int x){return x!=0;});
  8. return 0;
  9. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
8