Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to input a plastic number in C language without echo and without line break?
How to input a plastic number in C language without echo and without line break?
Enter with getch (). Numbers are separated by 1 spaces, and the last number is followed by a space or carriage return.

Use char str[300] to store input keys. Use sscanf () to convert it to int.

# include & ltstdio.h & gt

# include & ltconio.h & gt

Master ()

{

String [300];

int x[3][3],i=0,j,n = 0;

while( 1){

str[I]= getch();

if(str[I]= = ' ')n++;

if(str[I]= = ' \ n ')break;

If (n & gt=9) is broken;

i++;

}

sscanf(str," % d % d % d % d % d % d % d % d % d % d ",

& ampx[0][0],& ampx[0][ 1],& ampx[0][2],

& ampx[ 1][0],& ampx[ 1][ 1],& ampx[ 1][2],

& ampx[2][0],& ampx[2][ 1],& ampx[2][2]);

for(j = 0; j & lt3; j++) {

for(I = 0; I<3; i++) printf("%d ",x[j][I]);

printf(" \ n ");

}

Returns 0;

}