1 / 2
Sep 2019

hi everyone, i just solved The Next Palindrome problem, i’ve compiled the code and ran it on my computer and everything is perfect, but when i submit my solution it tells me that the solution is wrong.
any help please,
here is my code ( in C ) :
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int intlen(int x) {
int a;
int k=0;
a=(x/10);
while(a>=1){
a=(a/10);
k++;
}
return k;
}

int numver(int p) {
int a,i=0,test=0,num,comp;
int *coef;
fflush(stdin);
comp=intlen§;
coef=(int *) calloc(comp+1 , sizeof(int));

a=(int)(p/pow(10,comp));
p = (p-(a*pow(10,comp ) ));

while(i<comp+1) {
	*(coef+i) = a;
	a=(int)(p/pow(10,comp-i-1));
	p = (p-(a*pow(10,comp-i-1 ) ));
	i++;
}
for(i=0;i<comp+1;i++) {
	if (*(coef+i) != *(coef + comp-i)){
	test =1;
	break;
	}
}
free(coef);
return test;

}

int main () {
int p,i,ch;
int shit;
scanf("%d",&ch);
shit=(int
)calloc(ch,sizeof(int));
for(i=0;i<ch;i++) {
scanf("%d",shit+i);
}
for(i=0;i<ch;i++) {
p=*(shit+i);
fflush(stdin);
p++;
while(numver§ == 1) {
p++;
}
printf("%d\n",p);
}
}

  • created

    Sep '19
  • last reply

    Sep '19
  • 1

    reply

  • 611

    views

  • 2

    users

Suggested Topics

Want to read more? Browse other topics in Online Judge System or view latest topics.