Advertisement
Ahmed_Negm

Untitled

Mar 23rd, 2022
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. #include<iomanip>
  4. #include<algorithm>
  5. #include<cstdlib>
  6. #include<cstring>
  7. #include<vector>
  8.  
  9. #define ll long long
  10. #define sz(x) int(x.size())
  11. #define all(x) x.begin(),x.end()
  12. using namespace std;
  13.  
  14. void Fast_IO(){
  15.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  16.     #ifndef ONLINE_JUDGE
  17.         freopen("input.txt", "r", stdin), freopen("output.txt","w", stdout);
  18.     #endif
  19. }
  20.  
  21.  int n;
  22.  ll arr[105];
  23. double avg(ll idx, double result){
  24. if(idx == n) return result/n;
  25. return avg(idx+1,result+=arr[idx]);
  26. }
  27.  
  28. void solve(){
  29. cin>>n;
  30. for(int i =0; i<n; i++) cin>>arr[i];
  31.  
  32. cout<<fixed<<setprecision(6);
  33. cout<<avg(0,0);
  34.  
  35. }
  36.  
  37. int main(){
  38.     Fast_IO();
  39. int t =1;
  40. //cin>>t;
  41. while(t--){
  42. solve();
  43. }
  44. return 0;
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement