Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //You are given n integers. Find Median of given integers.
- //Input:
- //Inputs are positive integer n followed by n integers.
- //Output:
- //Output is the median of given integers. If n is even output is the average of two median values.
- #include<iostream>
- using namespace std;
- int main()
- {
- int a[100],n;
- float res=0;
- cin>>n;
- for(int i=0; i<n; i++)
- {
- cin>>a[i];
- res+=a[i];
- }
- cout<<endl;
- for(int i=0; i<n; i++)
- {
- cout<<a[i]<<" ";
- }
- cout<<endl;
- cout<<endl;
- cout<<res/n;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement