# 蓝桥杯刷题打卡Day1

T1：

#include <stdio.h>

#include <stdlib.h>

int main(int argc, char *argv[]) {

int result;

int temp1 = 1;

int temp2 = 1;

int temp3 = 1;

for (int i = 4; i <= 20190324; i++) {

result = (temp1 + temp2 + temp3) % 10000;

temp1 = temp2;

temp2 = temp3;

temp3 = result;

}

printf("%04d", result);

return 0;

}

T2：

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

int main() {

int track;

int i;

int temp[2019];

temp[2018] = 0;

int *p = temp + 1;

for (int j = 3;; j += 2) {

for (i = 2, track = 0; i <= sqrt(j); i++) {

if (j % i == 0) {

track = 1;

break;

}

}

if (track != 1) {

*p = j;

p++;

}

if (temp[2018] != 0)

break;

}

printf("%d", temp[2018]);

return 0;

}

T3：

#include <stdio.h>

#include <stdlib.h>

int compute(int temp) {

int cup = temp / 3;

if (cup == 0)

return 0;

else

return cup + compute(cup + temp % 3);

}

int main() {

int n;

scanf("%d", &n);

printf("%d", n + compute(n));

return 0;

}

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

3.1w+

2023-03-04 14:08

刷题！