Home > Back-end >  The first line contains a positive integer T, says the number of sets of input data. (1 <T <10
The first line contains a positive integer T, says the number of sets of input data. (1 <T <10

Time:10-05

For each group of input, output as input, the content of the

#include
#include
Int main ()
{
Char s [10] [20].
Int T, I;
The scanf (" % d ", & amp; T);
Getchar ();
for(i=0; i{
[I] gets (s);

}
for(i=0; i{

Printf (" % s \ n ", s [I]);

}

}

CodePudding user response:

Gets () function in C language bai du multiple character to read from input buffer function, meet with a carriage return, end zhi, input, when using the gets () function before had dao data input, and the operator input the return confirmation, the carriage return is not clear, are stored in the input buffer, gets () to read this character, end of read operation characters, therefore, from the user on the surface, gets () didn't work, skipped, solution: method 1, before gets () to add fflush (stdin);//to clear the cache the data in the (feasible) under Windows method 2, according to the program code, to determine whether the input statement, if any, is adding a getchar () command, and then call gets () command, method 3, check the input as a result, if the string is an empty string, then continue to read, such as: char STR [100]={0}; Do {gets (STR); } while (! STR [0]);
  • Related