#include
#include
Int main ()
{
Int a, b, c, d;
int i;
For (I=1000; i<10000; I++)
{
A=I/1000;//one thousand
B=(I % 1000)/100;//one hundred
C=(I % 100)/10;//10
D=I % 10;//bits
If (a==d& & B==c)
Printf (" % d \ t ", I);
}
return 0;
}
CodePudding user response:
What's the problem?CodePudding user response:
Another kind of writing, for reference:# include & lt; stdio.h>
Int main (void) {
int i, j;
int count=0;
For (I=1; i <10; + + I) {
For (j=0; J & lt; 10; + + j) {
Printf (" % d % d % d % d ", I, j, j, I);
Putchar (count & lt; 9? "' : '\ n');
Count=(count + 1) % 10;
}
}
return 0;
}
CodePudding user response:
# include & lt; stdio.h>
//# include & lt; math.h>
Int rt_revers (int num);
Int main ()
{
int i;
For (I=1000; i <10000; I++)
If (I==rt_revers (I))
Printf (" % d \ t ", I);
Putchar (10);
# if 0
Int a, b, c, d;
int i;
For (I=1000; i<10000; I++)
{
A=I/1000;//one thousand
B=(I % 1000)/100;//one hundred
C=(I % 100)/10;//10
D=I % 10;//bits
If (a==d& & B==c)
Printf (" % d \ t ", I);
}
# endif
return 0;
}
Int rt_revers (int num)
{
Int new_num=0;
While (num) {
New_num=new_num 10 * 10 + num %;
Num/=10;
}
Return new_num;
}
For any integer (note that the value of the int don't overflow)
# include & lt; stdio.h>
//# include & lt; math.h>
Int rt_revers (int num);
Int main ()
{
int i;
For (I=1000; i <10000; I++)
If (I==rt_revers (I))
Printf (" % d \ t ", I);
Putchar (10);
return 0;
}
Int rt_revers (int num)
{
Int new_num=0;
While (num) {
New_num=new_num 10 * 10 + num %;
Num/=10;
}
Return new_num;
}
Concise version ~
CodePudding user response: