#include<bits/stdc++.h>
using namespace std;
int main()
{
// int n;
// cout<<"Enter the length of the Array: ";
// cin>>n;
// int a[n];
// for (int i = 0; i <n; i++)
// {
// cin>>a[i];
// }
// for (int i = 0; i < n; i++)
// {
// for (int j = i+1; j <n; j++)
// {
// if (a[j]<a[i])
// {
// int temp;
// temp = a[j];
// a[j] = a[i];
// a[i] = temp;
// }
// }
// }
// for (int i = 0; i <n; i++)
// {
// cout<<a[i]<<" ";
// }cout<<endl;
// Short method of sorting array
int a[] = {1,7,2,8,3,12,3};
int n = sizeof(a)/sizeof(a[0]);
sort(a,a+n);
for (int i = 0; i < n; i++)
{
cout<<a[i];
}
return 0;
}
Comments
Post a Comment