Advertisement
ovi_salman

Problem No 24

Jul 30th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. //You are given n integers. Find Median of given integers.
  2. //Input:
  3. //Inputs are positive integer n followed by n integers.
  4. //Output:
  5. //Output is the median of given integers. If n is even output is the average of two median values.
  6.  
  7. #include<iostream>
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12. int a[100],n;
  13. float res=0;
  14. cin>>n;
  15.  
  16. for(int i=0; i<n; i++)
  17. {
  18. cin>>a[i];
  19. res+=a[i];
  20. }
  21. cout<<endl;
  22.  
  23.  
  24. for(int i=0; i<n; i++)
  25. {
  26. cout<<a[i]<<" ";
  27. }
  28. cout<<endl;
  29. cout<<endl;
  30.  
  31. cout<<res/n;
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement