Ok, so I tried the exercise over on https://www.spoj.pl/problems/PALIN/
The rules state:
"A positive integer is called a palindrome if its representation in the decimal system is the same when read from left to right and from right to left. For a given positive integer K of not more than 1000000 digits, write the value of the smallest palindrome larger than K to output. Numbers are always displayed without leading zeros."
I gave it my best shot, fellas, but it just won't compile. have a fucking field day, I'm spent for today.
The rules state:
"A positive integer is called a palindrome if its representation in the decimal system is the same when read from left to right and from right to left. For a given positive integer K of not more than 1000000 digits, write the value of the smallest palindrome larger than K to output. Numbers are always displayed without leading zeros."
I gave it my best shot, fellas, but it just won't compile. have a fucking field day, I'm spent for today.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void input(int *numberPointerOne);
int test(int *numberPointerTwo);
int *reverse(int*orig, unsigned short int b);
int main (int argc, const char * argv[]) {
int number[1000000];
int returned = 0;
int lengthTwo;
input(number);
while(returned = 0){
returned = test(number);
lengthTwo = strlen(number);
reverse(number, lengthTwo);
}
printf("%d", returned);
return 0;
}
void input(int *numberPointer){
printf("enter positive integer:\t");
scanf("%d", numberPointer);
fpurge(stdin);
}
int test(int *numberPointerTwo){
int lengthOne;
int before, after;
before = atoi(numberPointerTwo);
lengthOne = strlen(numberPointerTwo);
after = reverse(numberPointerTwo, lengthOne);
if(before == after){
return after;
} else{
return 0;
}
}
int *reverse(int *orig, unsigned short int b){
unsigned short int a=0;
int swap;
for(a;a<--b;a++){
swap=orig[a];
orig[a]=orig[b];
orig[b]=swap;
}
return orig;
}