fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. /*
  4. Rezolva problema fara if
  5. */
  6.  
  7. int main() {
  8. int length, currentNo, evensSum = 0, oddsSum = 0;
  9. cin >> length;
  10. for (int i = 1; i <= length; ++i) {
  11. cin >> currentNo;
  12. if (i % 2 == 0) {
  13. evensSum += currentNo;
  14. } else {
  15. oddsSum += currentNo;
  16. }
  17. }
  18. cout << evensSum - oddsSum;
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty