Blue Bridge Cup - Basic Training 08-- special palindrome

Special palindrome:

Problem Description
  123321 is a very special number, it is read from left to right and read from the same.
  Enter a positive integer n, find all such programming five and six decimal numbers, figures and meet all equal to n.
Input format
  input line, contains a positive integer n.
Output format
  in order from small to large outputs an integer satisfying the condition, each integer per line.
  
Input Sample
52
Sample Output
899 998
989 989
998 899

Data size and Conventions
  1 <= n <= 54.

code show as below:

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	int n,m,t,i,j,k,x,y,z;
	
	scanf("%d",&n);
	for(t=10000; t<100000; t++){
		i = (t/10000);
		j = (t-i*10000)/1000;
		k = (t-i*10000-j*1000)/100;
		x = (t-i*10000-j*1000-k*100)/10;
		y = (t-i*10000-j*1000-k*100-x*10);
		if (i==y && j==x && (i+j+k+x+y)==n){
			printf("%d\n",t);
		}
	} 
	
	for(m=100000; m<1000000; m++){
		i = (m/100000);
		j = (m-i*100000)/10000;
		k = (m-i*100000-j*10000)/1000;
		x = (m-i*100000-j*10000-k*1000)/100;
		y = (m-i*100000-j*10000-k*1000-x*100)/10;
		z = (m-i*100000-j*10000-k*1000-x*100-y*10);
		if (i==z && j==y && k==x && (i+j+k+x+y+z)==n){
			printf("%d\n",m);			
		}		
	}
	return 0;
}

Is so violent ~ Well!
next! !

Guess you like

Origin blog.csdn.net/weixin_44566432/article/details/88767771