Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- unsigned long v[100], s[100], n, i, st, dr;
- cout << "interval(st<dr):";
- cout << "st=";
- cin >> st;
- cout << "dr=";
- cin >> dr;
- cout << "n=";
- cin >> n;
- for (i = 0; i < n; i++)
- cin >> v[i];
- cout << endl;
- s[0] = v[0];
- for (i = 1; i < n; i++)
- s[i] = s[i - 1] + v[i];
- for (i = 0; i < n; i++)
- cout << s[i] << ' ';
- cout << endl;
- cout << "suma:" << s[dr] - s[st - 1];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement