Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. char A[100];
  6. gets_s(A);
  7. int sum = 0, position = 0, result = 0;
  8. for (int i = 0, temp = 0; i <= strlen(A); i++)
  9. {
  10. if (A[i] == ' ' || A[i] == '\0')
  11. {
  12. if (position % 2 == 1)
  13. {
  14. for (temp; temp < position; temp++)
  15. {
  16. if (A[temp] == '1')
  17. {
  18. result++;
  19. }
  20. }
  21. }
  22. temp = i;
  23. }
  24. position++;
  25. }
  26. cout <<"Kol-vo ones = "<< result<<endl;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement