Joao_Joao

Questão 273 Lista de Exercícios IFPB

Mar 18th, 2024
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int get_score(char * sequencia, int i) {
  5.     int size = strlen(sequencia);
  6.     if(i == size) return 0; // se ja chegamos ao final da string
  7.     int score = get_score(sequencia, i+1);
  8.     if(sequencia[i] == 'V') score += 3;
  9.     else if(sequencia[i] == 'E') score++;
  10.     return score;
  11. }
  12.  
  13. void main() {
  14.     char teste[15] = "VVVEEDDVED";
  15.     int score = get_score(teste, 0);
  16.    
  17.     printf("A pontuacao do time foi %d\n", score); // 15
  18.    
  19.     getch();
  20. }
  21.  
Add Comment
Please, Sign In to add comment