求大佬帮帮忙。

a1ioua 2020-12-08 19:28:48

#include <bits/stdc++.h>
#define ull unsigned long long
using namespace std;
inline ull in() {
	int s = 0, f = 1;
	char c = getchar();
	while (!isdigit(c)) {
		if (c == '-') f = -1;
		c = getchar();
	}
	while (isdigit(c)) {
		s = 10 * s + c - '0';
		c = getchar();
	}
	return s * f;
}
inline void out(ull n) {
	if (n < 0) {
		putchar('-');
		n = -n;
	}
	if (n >= 10) out(n / 10);
	putchar(n % 10 + '0');
	return ;
}
int main() {
	register ull n, a[1000005] = { 0 }, i;
	for (i = 1000000; i > 0; i--) {
		if (i > 100) a[i] = i - 10;
		else a[i] = a[a[i + 11]];
	}
	n = in();
	while (n != 0) {
		out(a[n]);
		putchar('\n');
		n = in();
	}
	return 0;
}

rt。

求助为什么不输出就直接结束了???

共 2 条回复

a1ioua

@jhhk77 谢谢!

jhhk77

a 数组开太大了,在函数里无法定义下标超过百万的数组,要定义在函数外并删除 register