Answer the question
In order to leave comments, you need to log in
How to find the minimum element of an array using recursion?
How to find the minimum element of an array using recursion? here is my code:
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <Windows.h>
#define N 100
int Min(int arr[], int n) {
}
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
srand(time(NULL));
int arr[N], n;
printf("n = ");scanf_s("%d", &n);
for (int i = 0; i < n; i++)
{
arr[i] = rand() % 355;
printf("%6d", arr[i]);
}
printf("\n");
printf("Min = %d", Min(arr, n));
return 0;
}
Answer the question
In order to leave comments, you need to log in
int Min(int arr[], int n, int current) {
return n > 0 ? Min(arr, n - 1, min(current, arr[n-1])) : current;
}
int minValue = Min(arr, n, +бесконечность)
int Min(int arr[], int n) {
return n > 0 ? min(Min(arr, n - 1), arr[n-1])) : +бесконечность;
}
int minValue = Min(arr, n);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question