Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- #include<conio.h>
- void main()
- {
- int ar[500], n, s, t;
- cout<<"Enter number of elements: ";
- cin>>n;
- cout<<"\n\n\n\n";
- for(int i=0; i<n; i++)
- {
- cout<<"Enter the value "<<(i+1)<<": ";
- cin>>ar[i];
- cout<<"\n";
- }
- cout<<"\n\n\n";
- for(int i=0; i<n; i++)
- {
- cout<<ar[i]<<" ";
- }
- for(int i=0; i<n-1; i++)
- {
- for(int j=i+1; j<n; j++)
- {
- if(ar[j]<ar[i])
- {
- ar[i]+=ar[j];
- ar[j]=ar[i]-ar[j];
- ar[i]-=ar[j];
- }
- }
- }
- cout<<"\n\nSorted array:\n\n";
- for(int i=0; i<n; i++)
- {
- cout<<ar[i]<<" ";
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement