Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int contaRepeticao (int v[], int n, int num)
- {
- int i , j , soma , max = -999 ;
- for (i = 0 ; i < n ; i++)
- {
- if (v[i] == num)
- {
- soma = 0 ;
- for (j = i ; (j < n) && (v[j] == num) ; j++) soma++ ;
- if (soma > max) max = soma ;
- }
- }
- return max ;
- }
- int main ()
- {
- int v[30] , n , num ;
- for (n = 0 ; v[n - 1] != -1 ; n++)
- {
- printf ("Introduza número : ") ;
- scanf ("%d" , &v[n]) ;
- }
- printf ("Número a pesquisar : ") ;
- scanf ("%d" , &num) ;
- printf ("Maior sequencia com números %d tem tamanho %d.\n" , num , contaRepeticao (v , n , num)) ;
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment