I have finished my helpers.c and handed it in thinking that it was good to go. When I execute it with find and generate like what was said in the lecture, it works perfectly fine. However, in my scoring card, it shows this:
Would anyone happens to know what's wrong with my code?
/**
* helpers.c
*
* Computer Science 50
* Problem Set 3
*
* Helper functions for Problem Set 3.
*/
#include <cs50.h>
#include "helpers.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
for (int i = 0; i < n; i++)
{
if (values[i] == value)
{
return true;
break;
}
}
return false;
}
/**
* Sorts array of n values.
*/
void sort(int values[], int n)
{
// TODO: implement an O(n^2) sorting algorithm
int j;
int p;
for (int a = 0; a < n-1; a++)
{
int min= values [a];
for (j = 1; j < n; j++)
{
if (values [j] < min)
{
min = values [j];
}
}
if (min != values [a])
p = values [a];
values [a] = values [j];
values [j] = p;
}
return ;
}
Thanks!