Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void scan(int* mas, int N){
- for (int i=0; i<N; i++){
- cout << "Введите "<<i<<" элемент массива: ";
- cin >> mas[i];
- }
- }
- int sum(int* mas, int N, int &K, int &L){
- int sum=0;
- for (int i=K; i<=L; i++){
- sum += mas[i];
- }
- return sum;
- }
- int main(){
- setlocale(LC_ALL,"rus");
- int* arr;
- int N, K, L;
- cin >> N >> K >> L;
- arr = new int[N];
- scan(arr, N);
- cout << sum(arr, N, K, L);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement