dllbridge

Untitled

Mar 24th, 2026
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1.  
  2.  
  3.  
  4. #include   <stdio.h>
  5. #include  <locale.h>       //  çäåñü "æèâ¸ò" setlocale(LC_ALL, "rus");
  6.  
  7.  
  8.  
  9. int nArr[99] = {7, 3, 0, 2, 7, 11, 223, 5, 0, 3, 67, 3,  1, 0, 887};  // 74
  10. int n = 15;
  11.  
  12.  
  13. int foo();
  14.  
  15. ////////////////////////////////////////////
  16. int main()
  17. {
  18.    
  19.     setlocale(LC_ALL, "rus");
  20.                
  21.     int n3 = foo();        
  22.                
  23.     printf("Ñóììà = %d\n", n3);    
  24.  
  25. return 0;
  26. }
  27.  
  28.  
  29.  
  30. //////////////////////////////////////////////
  31. int foo()
  32. {
  33.    
  34.      int    nA2[7];
  35.      int n2    = 1;
  36.      int nF    = 0;
  37.      int nPrev = 0;
  38.      int nSum  = 0;
  39.    
  40.      for(int i = 0; i < n; i++)
  41.      {
  42.        
  43.         if(nArr[i] == 0)
  44.         {
  45.            if(n2 == 1) nF = 1;
  46.            //else        nF = 0;
  47.            
  48.            if(n2%2 == 0)
  49.            {
  50.                
  51.               nPrev = nSum;
  52.                       nSum = 0;    
  53.            }   
  54.            n2 ++;
  55.         }  
  56.        
  57.         if(nF == 1) nSum = nSum + nArr[i];     
  58.      }
  59.      
  60.      
  61.      if(n2%2 == 1)
  62.      {
  63.         nSum = nPrev;  
  64.      }   
  65.      
  66. return nSum;     
  67. }
  68.  
  69.  
  70.  
  71.  
Advertisement
Add Comment
Please, Sign In to add comment