int main()
{
int arr[50],n;
cout<<"how many number"<<endl;
cin>>n;
for(int i=0; i<n; i++)
{
cout<<"enter the number"<<i+1<<":";
cin>>arr[i];
}
cout<<"THe orignal numbers are"<<endl;
for(int j=0; j<n; j++)
{
cout<<arr[j]<<endl;
}
int hold;
cout<<"Now the sorted vales are"<<endl;
for(int i=0; i<n; i++)
{
for(int j=0; j<n-1; j++)
{
if(arr[j]>arr[j+1])
{
hold=arr[j];
arr[j]=arr[j+1];
arr[j+1]=hold;
}// if end
}//nested for end
}//for end
cout<<"The sorted vales are"<<endl;
for(int i=0; i<n; i++)
{
cout<<arr[i]<<endl;
}
system("pause");
return 0;
}
0 comments:
Post a Comment