Blue Bridge Cup - Basic Training 07-- palindrome

Palindrome:

Problem Description
  1221 is a very special number, it is read and read from the right as from the left, seeking programming all such four-digit decimal number.
Output format
  output four decimal number satisfying the condition in ascending order.

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,i,j,k,l;
	
	for (n=1000; n<10000; n++){
		i = (n/1000);
		j = (n-i*1000)/100;
		k = (n-i*1000-j*100)/10;
		l = (n-i*1000-j*100-k*10);
		if(i==l && j==k){
			printf("%d\n",n);
		}
	} 
	return 0;
}

Hee hee, come on! Come on!
next!

Guess you like

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