Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int num;
- cin >> num;
- int number;
- int oddSum = 0;
- int evenSum = 0;
- for (int i = 1; i <= num; i++) {
- cin >> number;
- if (i % 2 == 1) {
- oddSum += number;
- }
- else {
- evenSum += number;
- }
- }
- if (oddSum == evenSum) {
- cout << "Yes" << endl;
- cout << "Sum = " << oddSum << endl;
- }
- else {
- cout << "No" << endl;
- cout << "Diff = " << abs(oddSum - evenSum) << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement