首页 > 代码库 > 输入一组数组,回车结束

输入一组数组,回车结束

#include<stdio.h>
int main(){
int a[10];
int n = 0, i;
char ch=0;
while (ch != ‘\n‘){
scanf_s("%d",&a[n]);
ch = getchar();
n++;
}
for (i = 0; i < n; i++)
printf("%d ", a[i]);
printf("\n");
return 0;
}

输入一组数组,回车结束