#include<iostream>
using namespace std;
int main()
{
int n;int*p;
int i=0,j=0,temp=0;
cin>>n;
p=new int[n];
for(int i=0;i<n;i++)
{
cin>>p[i];
}
for(j=0;j<n;j++)
{
for (i=j;i<n;i++)
{
if(p[i]>p[i+1])
{
temp=p[i];
p[i]=p[i+1];
p[i+1]=temp;
}
}
}
for(i=0;i<n;i++)
cout<<p[i]<<endl;
return 0;
}
yogesh_6
0
Newbie Poster
Recommended Answers
Jump to PostPlease help us to help you. What input do you give it, what output do you get,and how is that different from what you want? Is this intended to be a bubble sort implementation?
All 3 Replies
Moschops
683
Practically a Master Poster
Featured Poster
yogesh_6
0
Newbie Poster
Moschops
683
Practically a Master Poster
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.