Advertisement
Uncleeee

Untitled

Nov 19th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void scan(int* mas, int N){
  6. for (int i=0; i<N; i++){
  7. cout << "Введите "<<i<<" элемент массива: ";
  8. cin >> mas[i];
  9. }
  10. }
  11.  
  12. int sum(int* mas, int N, int &K, int &L){
  13. int sum=0;
  14. for (int i=K; i<=L; i++){
  15. sum += mas[i];
  16. }
  17. return sum;
  18. }
  19.  
  20. int main(){
  21. setlocale(LC_ALL,"rus");
  22. int* arr;
  23. int N, K, L;
  24. cin >> N >> K >> L;
  25. arr = new int[N];
  26. scan(arr, N);
  27. cout << sum(arr, N, K, L);
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement