-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
51 lines (40 loc) · 990 Bytes
/
main.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// main.cpp
// Sort_withNoIf
//
// Created by Andrey on 01.11.15.
// Copyright © 2015 Andrey. All rights reserved.
//
#include <iostream>
#include <stdlib.h>
#include <time.h>
constexpr unsigned int value_range()
{
return 10;
}
constexpr unsigned int count_range()
{
return 12;
}
int main(int argc, const char * argv[]) {
// insert code here...
int* arr = new int[count_range()];
/* initialize random seed: */
srand(static_cast<unsigned int>(time(nullptr)));
for (auto i=0; i<count_range(); ++i) {
arr[i] = rand() % value_range();
std::cout << arr[i] << ", ";
}
std::cout << std::endl;
unsigned int cnt_arr[value_range()] = {};
for (auto i=0; i<count_range(); ++i) {
auto value = arr[i];
++cnt_arr[value];
}
for (auto i=0; i<value_range(); ++i) {
for (auto j=0; j<cnt_arr[i]; ++j) {
std::cout << i << ", ";
}
}
return 0;
}