Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int getE()
- {
- int n, s = 1, e = 0;
- cout << "n="; cin >> n;
- for (int x = 2; x <= n * 2; x += 2, s = -s)
- {
- e += x * s;
- }
- return e;
- }
- int main()
- {
- cout << getE();
- return 0;
- }
Add Comment
Please, Sign In to add comment