因为输入一行空格隔开的字符,没说是以换行结束,而是EOF。。。。
int t = 0; char ch; do { scanf("%ld",&a[++t]); } while((ch=getchar())!='\n'&&ch!=EOF);