为什么在洛谷的ide上会re呢
查看原帖
为什么在洛谷的ide上会re呢
321232
coding可达鸭楼主2022/9/28 22:30
short a[510] = { 0 }, b[510] = { 0 };
int main() {
	

	int n;
	int i = 0, j = 0;
	while ((n = getchar()) != '\n')
	{
		i++;
		a[i] = n - 48;

	}

	while (1)
	{
		scanf("%c",&n);
		if (n == EOF||n=='\n') break;           //为什么这一块输入在洛谷就不行(会re) 在vs上就可以
		j++;
		b[j] = n - 48;
	}
	int max;
	if (j > i) max = j;
	else max = i;
	int k = max;

	if (i == max) {
		while (1) {
			if (i == j) break;
			b[i] = b[j];
			b[j] = 0;
			i--;
			j--;
			if (j == 0) break;
		}
	}
	else {
		while (1) {

			a[j] = a[i];

			a[i] = 0;
			i--;
			j--;
			if (i == 0) break;
		}
	}

	while (max >= 1) {
		if ((a[max] + b[max]) >= 10)
		{
			a[max - 1]++;
			a[max] = a[max] + b[max] - 10;
		}
		else  a[max] += b[max];
		max--;
	}

	int m = 1;
	if (a[0] > 0)   m--;
	while (m <= k) {
		printf("%d", a[m]);
		m++;
	}

	return 0;
}

救救孩子吧 感觉洛谷的ide好离谱啊

2022/9/28 22:30
加载中...