Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <stdbool.h>
- #define LEN 16
- bool binary_search(int V[], size_t v_len, int to_find);
- int main(void) {
- int V[LEN];
- srand(time(NULL));
- for (int i = 0; i < LEN; i++) {
- V[i] = rand() % 100 + 1;
- }
- printf("[ ");
- for (int i = 0; i < LEN; i++) {
- printf("%d ", V[i]);
- }
- printf("]\n");
- for (int i = 0; i < LEN; i++) {
- for (int j = i + 1; j < LEN; j++) {
- if (V[i] > V[j]) {
- int temp = V[i];
- V[i] = V[j];
- V[j] = temp;
- }
- }
- }
- printf("[ ");
- for (int i = 0; i < LEN; i++) {
- printf("%d ", V[i]);
- }
- printf("]\n");
- return 0;
- }
- bool binary_search(int V[], size_t v_len, int to_find) {
- // Restituire true se to_find esiste in V
- // False altrimenti
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement