Advertisement
Patresss

Untitled

Aug 16th, 2014
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. int solution(int A[], int N) {
  2.     // write your code in C90
  3. int min=100000;
  4. int i,P;
  5. int first,second;
  6. int difference;
  7.  
  8.  
  9.  
  10.     first=A[0];
  11.     second=0;
  12.     for(i=1;i<N;i++)
  13.        second+=A[i];
  14.     min=abs(second-first);
  15.    
  16. for(i=1;i<N;i++)
  17. {
  18.     first+=A[i];
  19.     second-=A[i];
  20. difference=abs(first-second);
  21. if (min>difference)
  22. min=difference;
  23. }
  24. return min;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement