Advertisement
Josif_tepe

Untitled

Mar 27th, 2022
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3. #include <algorithm>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <set>
  7. #include <cstring>
  8. #include <cmath>
  9. #include <map>
  10. #include <fstream>
  11. using namespace std;
  12. int n;
  13. int arr[505];
  14. int f(int i) {
  15.     if(i == n) {
  16.         return 0;
  17.     }
  18.     return f(i + 1) + arr[i];
  19. }
  20. int main() {
  21.     cin >> n;
  22.     for(int i = 0; i < n; i++) {
  23.         cin >> arr[i];
  24.     }
  25.     cout << f(0) << endl;
  26.    
  27.    return 0;
  28. }
  29. /*
  30.  
  31.  
  32.  */
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement