Advertisement
frost_any

Untitled

Aug 12th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. //Codigo do exercicio 2 da pagina 161 (livro Luis Damas)
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #define N 10
  5.  
  6. int retorno (float[], int);
  7. int main (void){
  8.   int analise (int);
  9.  
  10.   float vetor[N];
  11.   int numLim;
  12.  
  13.   printf("Digite 10 valores:\n");
  14.   for(int i=0;i<N;i++){
  15.     scanf("%f", &vetor[i]);
  16.   }
  17.  
  18.   printf("\nLimitacao de verificao(1~10):");
  19.   scanf("%d", &numLim);
  20.  
  21.   analise(retorno(vetor, numLim)); //<---- 'analise' recebe outra função que recebe dois argumentos
  22.   return 0;
  23. }
  24.  
  25. int analise (int lim){
  26. /*
  27. **o problema é que possivelmente essa função tambem lê o valor do array e imprime o argumento de 'else'
  28. */
  29.   if ((lim>=1) && (lim<=10)){
  30.     system ("clear");
  31.   }
  32.   else
  33.     printf("Limitacao excedida!\n");    
  34. }
  35.  
  36. int retorno (float v[N], int n){
  37.   float max;
  38.   max = v[0];
  39.  
  40.   for(int i=0;i<n;i++){
  41.     if(v[i] > max)
  42.       max = v[i];
  43.   }
  44.     printf("Maior Valor dos numeros digitados:[%.1f]\nLimitacao usada:[%d]", max, n);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement