Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Assign a value to the integer array a[ 10] in C language, get a[i] from the keyboard with scanf, and click the space bar to end the input.
Assign a value to the integer array a[ 10] in C language, get a[i] from the keyboard with scanf, and click the space bar to end the input.
# include & ltstdio.h & gt

Use namespace std

void main()

{

int a[ 100];

int I;

int t;

for(I = 0; I & lt=99; )

{

if((int)(a[i]=getchar())! =32)

{

i++;

t = I;

}

other

Break;

}

Printf ("The valid number entered is:");

for(I = 0; I<= t;; i++)

printf("%c ",a[I]);

}

When I enter the data test, I press Enter every time I enter a data (whether I enter a character or a number).

That is, press enter to distinguish the characters you entered. When you want to end the assignment, just enter a space and press Enter.

I added an extra input number before the output space myself. If there is anything wrong, please tell me.