fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int arr[6][4] = {
  5. 1,1,1,1,1,0,
  6. 1,1,1,1,0,0,
  7. 1,1,0,0,0,0,
  8. 1,0,0,0,0,0
  9. };
  10.  
  11. int countOnes(){
  12. int ans = 0, r = 6, c = 4, i = 0, j = c - 1;
  13. for(i = 0; i < r; i++){
  14. while(j>=0 && arr[i][j]==0)
  15. j--;
  16. ans+=(j+1);
  17. }
  18. return ans;
  19. }
  20.  
  21. int main() {
  22. int onesCount = countOnes();
  23. cout<<onesCount;
  24. return 0;
  25. }
Success #stdin #stdout 0s 4584KB
stdin
Standard input is empty
stdout
12