Herowaree

Palindromo em C

Nov 19th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "PILHA_SEQ.h"
  4.  
  5. int main(){
  6.  
  7. char string[1001];
  8.  
  9. gets(string);
  10.  
  11. struct Pilha pilha;
  12. iniciaPilha(&pilha);
  13.  
  14. int count, tam = strlen(string);
  15. for(count = 0; count < tam; count++){
  16. push(&pilha, string[count]);
  17. }
  18.  
  19. char string_invertida[1001];
  20. for(count = 0; count < tam; count++){
  21. string_invertida[count] = pop(&pilha);
  22. }
  23. string_invertida[count] = '\0';
  24.  
  25. if(strcmp(string_invertida, string) == 0){
  26. printf("A palavra %s e palindromica.\n", string);
  27. }else{
  28. printf("A palavra %s nao e palindromica.\n", string);
  29. }
  30.  
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment