
marceloruan
(usa Linux Mint)
Enviado em 02/02/2016 - 11:47h
cesar escreveu:
#include <stdio.h>
#include <stdlib.h>
int maior(int v[], int size)
{
if(size == 0)
return 0;
if(v[size-1] > maior(v,size-1))
return v[size-1];
else
return maior(v,size-1);
}
int main()
{
int vetor[10];
int i;
for (i = 0; i < 10; i++)
scanf("%d",&vetor[i]);
//vetor[0] = 2;
//vetor[1] = 45;
//vetor[2] = 3;
//vetor[3] = 89;
//vetor[4] = 23;
//vetor[5] = 5;
//vetor[6] = 9;
//vetor[7] = 12;
//vetor[8] = 21;
//vetor[9] = 15;
printf("MAIOR: %d", maior(vetor,10));
system("pause>null");
return 0;
}
//Créditos: Felipe Barbosa
//Estuda comigo ;d
Não entendi o uso da variável size.
Marcelo Ruan
Graduating in Technology in Telematics - IFPB CG
IEEE Student Member
Communications Coordinator in IEEE Student Branch - IFPB CG
Não alcançamos a liberdade buscando a liberdade, mas sim a verdade. A liberdade não é um fim, mas uma consequência.
Leon Tolstoi