Advertisement
Jonas_3k

/*-Recursão @ Comandos -*/

Apr 5th, 2012
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include<stdio.h>
  2. void SetPoint(char *,int,int);
  3. int  main()
  4. {
  5.     char string[255];
  6.     printf("Digite os comandos separados por ','\n# ");
  7.     fgets(string,255,stdin);
  8.     SetPoint(string,0,1);
  9.     return 0;
  10. }
  11.  
  12. void SetPoint(char *comandos,int indice,int palavra)
  13. {
  14.  
  15.     if(!indice && comandos[1] !='\0')
  16.     {
  17.         printf("Comando: %d ",palavra);
  18.         palavra++;
  19.     }
  20.     else if( comandos[indice] == '\0' )
  21.     {
  22.         return;
  23.     }
  24.     if( comandos[indice] != ',' )
  25.     {
  26.         putchar(comandos[indice]);
  27.         SetPoint(comandos,indice+1,palavra);
  28.     }
  29.     else
  30.     {
  31.         printf("\nComando: %d ",palavra);
  32.         indice++;
  33.         palavra++;
  34.         SetPoint(comandos,indice,palavra);
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement