Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- char A[100];
- gets_s(A);
- int sum = 0, position = 0, result = 0;
- for (int i = 0, temp = 0; i <= strlen(A); i++)
- {
- if (A[i] == ' ' || A[i] == '\0')
- {
- if (position % 2 == 1)
- {
- for (temp; temp < position; temp++)
- {
- if (A[temp] == '1')
- {
- result++;
- }
- }
- }
- temp = i;
- }
- position++;
- }
- cout <<"Kol-vo ones = "<< result<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement