# 蓝桥杯30天冲刺——今天＋补

三角回文数

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

int main(int argc, char* argv[])
{
int x = 0, y = 0, i, n;
for (i = 1;; i++)
{
x += i;
if (x > 20220514)
{
n = x;
while (n != 0)
{
y = n % 10 + y * 10;
n /= 10;
}
if (x == y)
{
printf("%d", x);
break;
}
y = 0;
}
}

return 0;
}

分数

#include<stdio.h>
#include<math.h>

int main()
{
int x, y;
x = pow(2, 20) - 1;
y = pow(2, 20);
printf("%d/%d", x, y);
return 0;
}

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

int main(int argc, char *argv[])
{
int days[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
int months[12] = { 1,2,3,4,5,6,7,8,9,10,11,12 };
int arr[8] = { 0 };
int n = 0;
scanf("%d", &n);
int l = n;
int i = 0;
int flag = 0;
int flag2 = 0;
for (i = n + 1; i < 99991231; i++)
{
int year = (i / 10000);
int zhong = i% 10000;
int month = zhong / 100;
int day = zhong % 100;

int j = 0;
int k = 0;

if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0)
{
days[1] = 29;

}
if (month > 12 || month <= 0)
{
continue;
}
if (day > days[month - 1] || day <= 0)
{
continue;
}

for (j = 3; j >= 0; j--)
{
arr[j] = year % 10;
year = year / 10;
}

arr[4] = month / 10;
arr[5] = month % 10;
arr[6] = day / 10;
arr[7] = day % 10;

if (arr[0] == arr[7] && arr[1] == arr[6] && arr[2] == arr[5] && arr[3] == arr[4])
{

flag++;
if (flag == 1)
{
for (k = 0; k < 8; k++)
{
printf("%d", arr[k]);

}
printf("\n");
}
if (arr[0]==arr[2]&& arr[2]== arr[5]&& arr[5]== arr[7]&& arr[1]== arr[3]&& arr[3] == arr[4]&& arr[4]== arr[6])
{
flag2++;
if (flag2 == 1)
{
for (k = 0; k < 8; k++)
{
printf("%d", arr[k]);
}
}

}
}

}
return 0;
}

...全文
6 回复 打赏 收藏 举报

3.2w+

2023-03-11 21:48

刷题！