Advertisement
Anik_Akash

average

Oct 7th, 2021
611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace    std;
  3.  
  4. #define flush                    cin.ignore(numeric_limits<streamsize>::max(),'\n')
  5. #define FASTERIO                 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  6. #define NL                       cout<<'\n';
  7. #define pi                       acos(-1.0) //3.1415926535897932384626
  8. #define pb                       push_back
  9. #define mk                       make_pair
  10. #define mx                       1000005
  11. #define EPS                      1e-10
  12. #define dpoint(x)                fixed<<setprecision(x)
  13. # define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
  14. typedef long long int            ll;
  15. typedef double                   dl;
  16. typedef unsigned long long int   ull;
  17.  
  18. int Find_avarage(int arr[], int n){
  19.     int sum=0, ava=0;
  20.     for(int i=0; i<n; i++){
  21.         sum+=arr[i];
  22.     }
  23.     return sum/n;
  24. }
  25.  
  26.  
  27. int main() {
  28.  
  29. #ifdef anikakash
  30.     clock_t tStart = clock();
  31.     freopen("input.txt", "r", stdin);
  32.     freopen("tmp.txt", "w", stdout);
  33. #endif
  34.  
  35.     FASTERIO; //cmt when use scanf & printf ;
  36.  
  37.     int n; cin>>n;
  38.     int arr[n];
  39.     for(int i=0; i<n; i++)cin>>arr[i];
  40.     int avarage = Find_avarage(arr, n);
  41.     cout<<"The avarage Value is : "<<avarage<<endl;
  42.  
  43. #ifdef anikakash
  44.     fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
  45. #endif
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement