#include<iostream>
using namespace std;
int main ()
{
int a[100],i,j,n,swap;
cout<<"How many number"<<endl;
cin>>n;
cout<<"Enter the number"<<endl;
for(i=0;i<=n;i++)
cin>>a[i];
for(i=0;i<=n-1;i++)
{
for(j=0;j<=n-i-1;j++)
{
if(a[j+1]<a[j])
{
swap=a[j];
a[j]=a[j+1];
a[j+1]=swap;
}
}
}
cout<<"After assending the number's"<<endl;
for(i=0;i<=n;i++)
cout<<a[i]<<" ";
return 0;
}
using namespace std;
int main ()
{
int a[100],i,j,n,swap;
cout<<"How many number"<<endl;
cin>>n;
cout<<"Enter the number"<<endl;
for(i=0;i<=n;i++)
cin>>a[i];
for(i=0;i<=n-1;i++)
{
for(j=0;j<=n-i-1;j++)
{
if(a[j+1]<a[j])
{
swap=a[j];
a[j]=a[j+1];
a[j+1]=swap;
}
}
}
cout<<"After assending the number's"<<endl;
for(i=0;i<=n;i++)
cout<<a[i]<<" ";
return 0;
}
Output
No comments:
Post a Comment