#include <stdio.h>
#include <stdlib.h>
#define MAX_SIZE 1000
int main() {
int a, b;
int* results = (int*)malloc(MAX_SIZE * sizeof(int)); // 动态分配内存存储结果
int count = 0; // 记录有效结果的数量
if (results == NULL) {
printf("内存分配失败\n");
return 1;
}
while (1) {
scanf("%d %d", &a, &b);
if (a == 0 && b == 0) {
break;
}
results[count++] = a + b; // 存储计算结果,并增加计数
// 检查是否超出预设的最大存储数量
if (count >= MAX_SIZE) {
printf("存储数量超出预设最大值\n");
break;
}
}
// 一次性输出所有结果
for (int i = 0; i < count; i++) {
printf("%d\n", results[i]);
}
free(results); // 释放动态分配的内存
return 0;
}