Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Copyright (c) 2013
- * Bruno da Silva
- * Checa se string é palindromo
- */
- palindromo(texto[]) {
- static i, j;
- j = 0;
- i = strlen(texto) - 1;
- for( ; i != j && i > -1; j++, --i) {
- if( tolower(texto[i]) != tolower(texto[j])) return false;
- }
- return true;
- }
- printf("%d", palindromo("nauan")); // 1
- printf("%d", palindromo("ana")); // 1
- printf("%d", palindromo("metem")); //1
- printf("%d", palindromo("mete")); //0
- printf("%d", palindromo("anas")); // 0
- printf("%d", palindromo("luan")); // 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement