diff options
| author | tylov <[email protected]> | 2023-07-24 08:30:30 +0200 |
|---|---|---|
| committer | tylov <[email protected]> | 2023-07-24 08:30:30 +0200 |
| commit | d9464e7ddfa70860ca09d373d01dc1a6f7730271 (patch) | |
| tree | d330424ab73e8ca528dce312f3bf15afa8ac2ede /misc/examples | |
| parent | e4c169a66c3d55a4d0d3407f47102e54d289a3fb (diff) | |
| parent | 177418232a2d8a8b0df1667d3e4bd15dc37db59f (diff) | |
| download | STC-modified-d9464e7ddfa70860ca09d373d01dc1a6f7730271.tar.gz STC-modified-d9464e7ddfa70860ca09d373d01dc1a6f7730271.zip | |
Merge branch 'master' into dev43
Diffstat (limited to 'misc/examples')
| -rw-r--r-- | misc/examples/algorithms/random.c | 2 | ||||
| -rw-r--r-- | misc/examples/bitsets/prime.c | 4 | ||||
| -rw-r--r-- | misc/examples/linkedlists/intrusive.c | 2 | ||||
| -rw-r--r-- | misc/examples/queues/queue.c | 2 |
4 files changed, 6 insertions, 4 deletions
diff --git a/misc/examples/algorithms/random.c b/misc/examples/algorithms/random.c index ccd0711d..fd904b0f 100644 --- a/misc/examples/algorithms/random.c +++ b/misc/examples/algorithms/random.c @@ -4,7 +4,7 @@ int main(void) { - long long N = 1000000000; + const int N = 10000000; const uint64_t seed = (uint64_t)time(NULL), range = 1000000; crand_t rng = crand_init(seed); diff --git a/misc/examples/bitsets/prime.c b/misc/examples/bitsets/prime.c index 462526a2..8216e332 100644 --- a/misc/examples/bitsets/prime.c +++ b/misc/examples/bitsets/prime.c @@ -31,9 +31,12 @@ int main(void) clock_t t = clock(); cbits primes = sieveOfEratosthenes(n + 1); + llong np = cbits_count(&primes); t = clock() - t; + printf("Number of primes: %lld, time: %f\n\n", np, (float)t / (float)CLOCKS_PER_SEC); + puts("Show all the primes in the range [2, 1000):"); printf("2"); c_forrange (i, 3, 1000, 2) @@ -50,7 +53,6 @@ int main(void) printf("%lld ", *i.ref); if (c_flt_getcount(i) % 10 == 0) puts(""); } - printf("Number of primes: %lld, time: %.2f\n\n", np, (double)t/CLOCKS_PER_SEC); cbits_drop(&primes); } diff --git a/misc/examples/linkedlists/intrusive.c b/misc/examples/linkedlists/intrusive.c index c22ed260..c7402d09 100644 --- a/misc/examples/linkedlists/intrusive.c +++ b/misc/examples/linkedlists/intrusive.c @@ -17,7 +17,7 @@ void printList(List list) { int main(void) { List list = {0}; c_forlist (i, int, {6, 9, 3, 1, 7, 4, 5, 2, 8}) - List_push_back_node(&list, c_new(List_node, {0, *i.ref})); + List_push_back_node(&list, c_new(List_node, {.value=*i.ref})); printList(list); diff --git a/misc/examples/queues/queue.c b/misc/examples/queues/queue.c index 913524cc..5b1f7606 100644 --- a/misc/examples/queues/queue.c +++ b/misc/examples/queues/queue.c @@ -6,7 +6,7 @@ #include <stc/cqueue.h> int main(void) { - int n = 100000000; + int n = 1000000; crand_uniform_t dist; crand_t rng = crand_init(1234); dist = crand_uniform_init(0, n); |
