HDU1282 回文数猜想[入门+]

using namespace std;
#include <iostream>

bool isPalindrome(int n,int &t){
	int temp1=n;
	
	t=0;
	while(n>0){
		t=t*10+n%10;
		n/=10;
	}
	
	return temp1==t;
}

int main(){
	int a,v[100],count,temp,i;
	
	while(~scanf("%d",&a)){//~是位反,输入结束时,往下跑
		v[0] =a;
		count =0;
		
		for(;;){
			if(isPalindrome(a,temp)){
				break;
			}
			else{
				a+=temp;
				v[++count]=a;
			}
		}
		printf("%d\n",count);
		for(i=0;i<=count;i++){
			if(i==0)
				printf("%d",v[i]);
			else 
				printf("--->%d",v[i]);
		}
		printf("\n");
	}
	return 0;
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-26
  • 2021-09-12
  • 2021-12-23
  • 2021-12-13
  • 2021-12-20
猜你喜欢
  • 2022-01-02
  • 2022-03-06
  • 2022-12-23
  • 2021-07-01
  • 2021-07-25
  • 2021-10-16
相关资源
相似解决方案