Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example program
- #include <iostream>
- #include <string>
- using namespace std;
- int sum(int* v, int n)
- {
- int sum = 0;
- for (int i = 0; i < n; i++)
- sum += v[i];
- return sum;
- }
- int main()
- {
- int n;
- cout<<"n = ";
- cin>>n;
- int v[n];
- for (int i = 0; i < n; i++)
- {
- cout<<"v[ "<< i << "] = ";
- cin>>v[i];
- cout<<endl;
- }
- for (int i = n; i > 0; i--)
- cout<<sum(v, i)<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement