forked from Ananya02850/HacktoberFest-2022
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSort.cpp
More file actions
40 lines (37 loc) · 605 Bytes
/
Copy pathSort.cpp
File metadata and controls
40 lines (37 loc) · 605 Bytes
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
38
39
40
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
int arr[n], zero = 0, one = 0;
for (int i = 0; i < n; i++)
{
cin >> arr[i];
if (arr[i] == 0)
zero++;
else if (arr[i] == 1)
one++;
}
int two = n - zero - one, i = 0;
while (zero--)
{
arr[i] = 0;
i++;
}
while (one--)
{
arr[i] = 1;
i++;
}
while (two--)
{
arr[i] = 2;
i++;
}
for (int i = 0; i < n; i++)
{
cout << arr[i] << " ";
}
cout << endl;
}