Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- //#include <stdio.h>
- using namespace std;
- bool splitArray(int vec[], int size){
- for (int i = 0; i<=size; i++)
- {
- int k=0, l=0;
- for (int j=0;j<=i;j++)
- {
- k=k+vec[j];
- l=l+vec[size-j+1];
- }
- if (k==l) return true;
- }
- }
- int main(){
- int p;
- int test1[1] = {1};
- cout << splitArray(test1,1) << endl; // FALSE
- int test2[5] = {1, 1, 1, 2, 1};
- cout << splitArray(test2,5) << endl; // TRUE
- int test3[5] = {2, 1, 1, 2, 1};
- cout << splitArray(test3,5) << endl; // FALSE
- int test4[5] = {10, 0, 1, -1, 10};
- cout << splitArray(test4,5) << endl; // TRUE
- int test5[2] = {10, 10};
- cout << splitArray(test5,2) << endl; // TRUE
- int test6[7] = {1, 2, 3, 1, 0, 2, 3};
- cout << splitArray(test6,7) << endl; // TRUE
- cout<<"pauza";
- cin>>p;
- //getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement