C++回文数

2024-11-19 02:37:50
推荐回答(1个)
回答(1):

//#include "stdafx.h"//vc++6.0加上这一行.
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
int main(void){
int n,T,tmp;
char a[11];
printf("How many sample?\nn=");
scanf("%d",&n);
while(n--){
while(1){
printf("Input T(0 if(scanf("%d",&T),T<100000000 && T>0) break;
printf("Error,input again: ");
}
while(1){
if(T!=(tmp=atoi(strrev(itoa(T,a,10)))))
T+=tmp;
else{
printf("%d\n",T);
break;
}
}
printf("\n");
}
return 0;
}