蓝桥杯回文日期
作者:互联网
#include<stdio.h>
int main()
{
int N;
int a, b, c, d, e, f, g, h;
int A, B, C, D, E, F, G, H;
int x=0, y=0;
scanf_s("%d", &N);
int i = N + 1;
do
{
i++;
a = i % 10;
b = (i / 10) % 10;
c = (i / 100) % 10;
d = (i / 1000) % 10;
e = (i / 10000) % 10;
f = (i / 100000) % 10;
g = (i / 1000000) % 10;
h = (i / 10000000) % 10;
if ((a == h) && (b == g) && (c == f) && (d == e))
{
x = i;
printf("%d\n", x);
}
} while (x == 0);
i = N + 1;
do
{
i++;
A = i % 10;
B = (i / 10) % 10;
C = (i / 100) % 10;
D = (i / 1000) % 10;
E = (i / 10000) % 10;
F = (i / 100000) % 10;
G = (i / 1000000) % 10;
H = (i / 10000000) % 10;
if ((A == C)&&(C == F)&&(F == H) && (B == D)&&(D == E)&&(E == G))
{
y = i;
printf("%d", y);
}
} while (y == 0);
return 0;
}
考察如何提取一个数的每位数
标签:10,10000000,10000,int,蓝桥,日期,&&,printf,回文 来源: https://blog.csdn.net/Alexislyn/article/details/115257646