Advertisement
Guest User

flippinggamecristi2

a guest
May 28th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int n,i,j,k,x,y=0;
  5. int a[100];
  6. int b[100];
  7.  
  8. int main()
  9. {
  10. cin>>n;
  11. for(x=1;x<=n;x++)
  12. cin>>a[x];
  13. for(i=1;i<=n;i++)
  14. for(j=1;j<=n;j++)
  15. {
  16. if(i<=j)
  17. {
  18. k=0;
  19. for(x=1;x<=n;x++)
  20. b[x]=a[x];
  21. for(x=i;x<=j;x++)
  22. {
  23. b[x]=1-b[x];
  24. }
  25. for(x=1;x<=n;x++)
  26. if(b[x]==1)
  27. k++;
  28. if(y<=k)
  29. y=k;
  30. }}
  31.  
  32. cout<<y<<endl;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement