#include <iostream.h>
void main(void)
{
int t,i,j;
int n;
cout<<"Enter the number of values to be sorted ";
cin>>n;
int s[20];
cout<<"\nEnter values ";
for(i=0;i<n;i++)
cin>>s[i];
cout<<endl;
cout<<"sorted list is ";
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if (s[j]>s[j+1])
{
t=s[j+1];
s[j+1]=s[j];
s[j]=t;
}
}
cout<<endl;
cout<<"Pass "<<i+1<<" ";
for(int k=0;k<n;k++)
cout<<s[k]<<" ";
}
cout<<endl;
}
void main(void)
{
int t,i,j;
int n;
cout<<"Enter the number of values to be sorted ";
cin>>n;
int s[20];
cout<<"\nEnter values ";
for(i=0;i<n;i++)
cin>>s[i];
cout<<endl;
cout<<"sorted list is ";
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if (s[j]>s[j+1])
{
t=s[j+1];
s[j+1]=s[j];
s[j]=t;
}
}
cout<<endl;
cout<<"Pass "<<i+1<<" ";
for(int k=0;k<n;k++)
cout<<s[k]<<" ";
}
cout<<endl;
}
not working . wrong program
ReplyDelete