T

@thang_nguyen

generate a random floating point number between a and b

C
3 years ago
/* Include lib */ #include <stdio.h> #include <assert.h> #include <stdlib.h> /* Define */ #define MAX_LOOP 100 /* API generate positive random float number */ /* NOTE: not care a > b & vice versa */

Determine sum of three integers

C
3 years ago
/* Include lib */ #include <stdio.h> #include <assert.h> /* Define */ #define ARRAY_MAX 7 #define ARRAY_INPUT { 3, 7, 1, 2, 8, 4, 5 } #define EXPECT_VAL 21

Find all sum combinations

C
3 years ago
/* Include lib */ #include <stdio.h> #include <assert.h> #include <string.h> /* Define */ #define ARRAY_MAX 19 #define ARRAY_INPUT { 1, 4, 2, 3, 1, 1, 3, 1, 2, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1 } #define EXPECT_VAL 5

Sort 4 numbers using 2 number sorters(as many as you want)

C
3 years ago
/* Include lib */ #include <stdio.h> #include <assert.h> /* Define */ #define ARRAY_MAX 4 #define ARRAY_INPUT { 5, 7, 0, 1} int array_input[ARRAY_MAX] = ARRAY_INPUT;

Largest Sum Subarray

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

Add two integers

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

C program to sort array. Binary search vs Linear Search. Time complexity.

C
3 years ago
/* Include lib */ #include <stdio.h> #include <assert.h> /* Define */ #define ARRAY_MAX 16 #define ARRAY_INPUT { 0, 5, 7, 2, 5, 10, -1, 9, \ 2, 3, 6, 8, 9, 12, -9, 14 } #define FIND_VALUE 3

Whether a number is 2^k for some natural k

C
3 years ago
/* Include lib */ #include <stdio.h> #include <assert.h> /* Define */ /* API calc power of 2 */ /* Calc 2^k with k is natural number (positive integer, except 0) */ int power_of_2(int k, int *ret) {

You accept an integer, return the reversed number in his bit representation

C
3 years ago
/* * This request is similar reverse bit in another request * -> check reverse_bit_tg. However that coding is for 2 cases: * - Reverse FULL 32 bits * - Reverse exact the number counted from first bit 1 to end (ex: 0x3A --> b'11 1010) * * In this request will reverse exactly input from user as 0x3A */ /* Include lib */