Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <locale.h> // çäåñü "æèâ¸ò" setlocale(LC_ALL, "rus");
- int nArr[99] = {7, 3, 0, 2, 7, 11, 223, 5, 0, 3, 67, 3, 1, 0, 887}; // 74
- int n = 15;
- int foo();
- ////////////////////////////////////////////
- int main()
- {
- setlocale(LC_ALL, "rus");
- int n3 = foo();
- printf("Ñóììà = %d\n", n3);
- return 0;
- }
- //////////////////////////////////////////////
- int foo()
- {
- int nA2[7];
- int n2 = 1;
- int nF = 0;
- int nPrev = 0;
- int nSum = 0;
- for(int i = 0; i < n; i++)
- {
- if(nArr[i] == 0)
- {
- if(n2 == 1) nF = 1;
- //else nF = 0;
- if(n2%2 == 0)
- {
- nPrev = nSum;
- nSum = 0;
- }
- n2 ++;
- }
- if(nF == 1) nSum = nSum + nArr[i];
- }
- if(n2%2 == 1)
- {
- nSum = nPrev;
- }
- return nSum;
- }
Advertisement
Add Comment
Please, Sign In to add comment