tyrion

palindromo.c

Nov 7th, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int palindromo(int array[], int length) {
  4.     int i;
  5.     for (i = 0; i < length / 2; i++) {
  6.         if (array[i] != array[length-1-i])
  7.             return 0;
  8.     }
  9.     return 1;
  10. }
  11.  
  12. main() {
  13.     int test[] = {2, 1, 0, 1, 2};
  14.     printf("%d\n", palindromo(test, 5));
  15. }
  16.  
Advertisement
Add Comment
Please, Sign In to add comment