0

I must be missing something on my code for pset3. When i run the Check50 i get this messages :

:) finds 42 in {41,42,43}
:( finds 42 in {40,41,42}
   \ expected an exit code of 0, not 1

After running my ./find it does though find the 42 within that array, then when I execute check $? it does return 0.

Is this linked to the bug reported here : Pset3 Find Check50 is Inconsistent

Or is it me doing something wrong?

Thank you guys,

10
  • I don't think it's the same bug. Do you in any case have a command to return 1 if the number wasn't found in the array? Consider pasting your code.
    – ChrisG
    Commented Aug 1, 2015 at 16:56
  • yeah, I have the return 1 if the number wasn't found. Here is my code bool search(int value, int values[], int n) { int i; int m=n/2; // rejects negative numbers if (n < 0) { return false; } else { // Binary search for (i=0;i<n;i++){ // max value is less than n if (values[m] > value) {m = m/2;} else {m = m*1.5;}; // integer m autorounds if (values[m]==value){return true;}; } return false; } }
    – jon.tre
    Commented Aug 1, 2015 at 17:50
  • what kind of annoys me is not being able to see from the error message what i get wrong, since when i execute the programme, everything "seems" fine. :) , i don't see the pattern of errors in these : finds 42 in {42,43,44} :) finds 42 in {41,42,43} :( finds 42 in {40,41,42} \ expected an exit code of 0, not 1 :( finds 42 in {41,42,43,44} \ expected an exit code of 0, not 1 :( finds 42 in {40,41,42,43} \ expected an exit code of 0, not 1 :) finds 42 in {39,40,41,42} :) doesn't find 42 in {39,40,41} :) doesn't find 42 in {39,40,41,43}
    – jon.tre
    Commented Aug 1, 2015 at 17:55
  • The specification doesn't want you to return something if the number wasn't found. Delete this line.
    – ChrisG
    Commented Aug 1, 2015 at 17:57
  • thanks, so i tried to to that but it either told me that non-void function 'search' should return a value or control may reach end of non-void function which kind of make sense to me since you want to know if your search was successful, right?
    – jon.tre
    Commented Aug 1, 2015 at 18:18

0

You must log in to answer this question.

Browse other questions tagged .