for(i=0;a[i]!='\n';i++) { scanf("%d",&a[i]); }

for(i=0;a[i]!='\n';i++)

{

scanf("%d",&a[ i]);

}

Execute scanf("%d",&a[i]); after judging a[i]!='\n'; then execute i++ Then judge a[i]!='\n'

At this time, a[i] is in a state of no assignment, so a[i]!='\n' will never be true

If you don’t understand, you can ask questions