Created
August 1, 2017 14:52
-
-
Save b4284/7a443bd1abea8cbeadb4414bfb2f5fa0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdint.h> | |
| static inline void print_nums(const uint8_t *u8) | |
| { | |
| for (int i = 0; i < 5; ++i) { | |
| printf(" %d", u8[i]); | |
| } | |
| putchar('\n'); | |
| } | |
| void move_zeroes_last(uint8_t *u8) { | |
| int iters = 0; | |
| for (int i = 0; i < 5; ++i) { | |
| if (u8[i] == 0) { | |
| for (int q = i + 1; q < 5; ++q) { | |
| iters += 1; | |
| if (u8[q] != 0) { | |
| int s = u8[q]; | |
| u8[q] = u8[i]; | |
| u8[i] = s; | |
| break; | |
| } | |
| } | |
| } | |
| } | |
| printf("Iterations: %d\n", iters); | |
| } | |
| int fib(int n) { | |
| if (n <= 2) { | |
| return 1; | |
| } | |
| return fib(n - 1) + fib(n - 2); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment