C语言输入不确定数量的数字
#include <stdio.h>
int main() {
char ch;
int n, k = 0;
int arr[100] = { 0 };
while((ch = getchar()) && ch != '\n') {
ungetc(ch, stdin);
scanf("%d", &n);
arr[k++] = n;
}
for (int i = 0; i < k; i++) {
printf("%d ", arr[i]);
}
return 0;
}