Use code tags or Kermi3 will be after you!!!
Only for code that is in c++ and will run correctly.
Since the code I gave is neither I suppose I don't
have to use code tags.
Here is some correct code
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 100
int smallest(int A[], int i, int j)
{
int q;
int left, right;
if (i >= j)
return A[i];
q = (i + j)/2;
left = smallest(A, i, q);
right = smallest(A, q + 1, j);
if (left < right)
return left;
return right;
}
int main(void)
{
int A[N];
int i;
srand(time(NULL));
for (i = 0; i < N; ++i)
{
A[i] = rand() % N;
printf("%3d ", A[i]);
if ((i + 1) % 12 == 0)
printf("\n");
}
printf("\n");
printf("smallest = %d\n", smallest(A, 0, N - 1));
return 0;
}