-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaior_chall.c
41 lines (36 loc) · 894 Bytes
/
maior_chall.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <string.h>
#include <stdio.h>
int array_scan(int a[],int i)
{
int n1;
scanf("%d",&n1);
if (n1 == 0)
{
return i;
}
a[i] = n1;
return array_scan(a,i+1);
}
void array_greatest(int a[], int indice, int tamanho, int maior,int indice_maior) //imprime o valor maior do array, com seu indice
{
if(indice == tamanho)
{
//printf("[%d] MAIOR:%d, INDICE DO MAIOR:%d\n",indice, maior,indice_maior);
printf("%d\n",maior);
return;
}
if(a[indice] > a[indice_maior])
{
maior = a[indice];
indice_maior = indice;
}
//printf("[%d] MAIOR:%d, INDICE DO MAIOR:%d\n",indice, maior,indice_maior);
array_greatest(a,indice+1,tamanho,maior,indice_maior);
}
int main()
{
int array[10000];
int num_alg = array_scan(array,0);
array_greatest(array,0,num_alg,0,0);
return 0;
}