Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int switched (int number, int switcher) {
- if (!number)
- return switcher;
- return switched (number/10, number%10 + 10*switcher);
- }
- int isPalindrom (int number) {
- return number == switched (number,0);
- }
- int main () {
- int number,N,K = 0;
- scanf("%d", &N);
- int array [N];
- for(int i=0; i<N; ++i) {
- scanf("%d", &number);
- if(isPalindrom (number + switched(number,0)))
- array[K++] = number;
- }
- for(int i=0; i<K; ++i)
- printf("%d ", array[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment