Advertisement
ipsBruno

(Pawn) palindromo

Oct 2nd, 2013
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.55 KB | None | 0 0
  1. /*
  2. * Copyright (c) 2013
  3. * Bruno da Silva
  4. * Checa se string é palindromo
  5. */
  6.  
  7. palindromo(texto[]) {
  8.  
  9.     static i, j;
  10.    
  11.     j = 0;
  12.     i = strlen(texto) - 1;
  13.    
  14.     for( ; i != j && i > -1; j++, --i) {
  15.         if( tolower(texto[i]) != tolower(texto[j])) return false;
  16.     }
  17.  
  18.     return true;
  19. }
  20.  
  21.  
  22.  
  23. printf("%d", palindromo("nauan")); // 1
  24.  
  25. printf("%d", palindromo("ana")); // 1
  26. printf("%d", palindromo("metem")); //1
  27.  
  28. printf("%d", palindromo("mete")); //0
  29. printf("%d", palindromo("anas")); // 0
  30. printf("%d", palindromo("luan")); // 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement