forked from ambujraj/hacktoberfest2018
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sorting.cpp
37 lines (37 loc) · 793 Bytes
/
sorting.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int num;
cout << "Enter the number of element in UNSORTED array!! : ";
cin >> num;
int a[num];
cout << "Enter the value in UNSORTED array" << endl;
for (int i = 0; i < num; i++)
{
if (i == 0)
{
cout << i + 1 << "st element: ";
}
else if (i == 1)
{
cout << i + 1 << "nd element: ";
}
else if (i == 2)
{
cout << i + 1 << "rd element: ";
}
else
{
cout << i + 1 << "th element: ";
}
cin >> a[i];
}
sort(a,a+num);
cout << "The SORTED array is:" << endl;
for (int i = 0; i < num; i++)
{
cout << a[i] << " ";
}
}