Created
May 29, 2017 16:12
-
-
Save awareness481/f3dfa6c53df88f36bf6378e45da12872 to your computer and use it in GitHub Desktop.
control may reach end of non-void function [-Werror,-Wreturn-type] }
This file contains 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 <cs50.h> | |
#include <string.h> | |
#include "helpers.h" | |
#include <stdio.h> | |
/** | |
* Returns true if value is in array of n values, else false. | |
*/ | |
bool search(int value, int values[], int n) | |
{ | |
// TODO: implement a searching algorithm | |
if (n < 1) { | |
return false; | |
} | |
sort(values, n); | |
} | |
/** | |
* Sorts array of n values. | |
*/ | |
void sort(int values[], int n) { | |
if (n == 1) { | |
} | |
int left[n/2]; | |
int right[n/2]; | |
memcpy(left, values, sizeof left); | |
memcpy(right, values + n/2, sizeof right); | |
for (int i = 0, n = sizeof( right ) / sizeof( right[0]); i < n; i++) { //test | |
printf("%d", right[i]); | |
} | |
} |
This file contains 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
/** | |
* helpers.h | |
* | |
* Helper functions for Problem Set 3. | |
*/ | |
#include <cs50.h> | |
/** | |
* Returns true if value is in array of n values, else false. | |
*/ | |
bool search(int value, int values[], int n); | |
/** | |
* Sorts array of n values. | |
*/ | |
void sort(int values[], int n); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment