Advertisement
Guest User

???

a guest
Sep 17th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. bool kt=false;
  5. int sum=0,buff=0;
  6. void nhap(vector <int> &a)
  7. {
  8. int x;
  9. while (cin>>x)
  10. a.push_back(x);
  11. }
  12. void kiemtra(vector <int> &a)
  13. {
  14. for (int i=0; i<a.size();i++)
  15. sum+=a[i];
  16. for (int i=0; i<(a.size()-1);i++)
  17. {
  18. buff+=a[i];
  19. if(buff==sum/2)
  20. kt=true;
  21. }
  22. }
  23. void output()
  24. {
  25. if (kt==true)
  26. cout<<"True";
  27. else
  28. cout<<"False";
  29. }
  30. int main()
  31. {
  32. vector <int> a;
  33. nhap(a);
  34. kiemtra(a);
  35. output();
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement