Introduction to the classic algorithm contest the second edition of essays 1

while (scanf ( "% d", & x) == 1) where the number of variables scanf returns successfully entered, when the end of input, the function scanf x can not be read again, returns 0

Relatively large arrays should try statement outside the main function, or the program may not run

On the array c language: If you want to copy a k array elements to b, you can do this: memcpy (b, a, sizeof (int) * k). Of course, if a and b are an array of floating-point, should be rewritten when copying memcpy (b, a, sizeof ( double) * k). Also note that the use of memcpy
function to include the header file string.h If you need to copy a whole array to array b, you can write a simple point, memcpy (b, a, sizeof (a)).

Effect memset (a, 0, sizeof (a)) of the array is a clear, defined in string.h

Defines the size of the character array s is 20, but not have to spend all of the space, if the input is "2357", then it s actually saves only five characters (do not forget that there is an end tag "\ 0" ), followed by 15 characters is uncertain. strlen (s) is returned by the end of the standard
number of characters referred to before.

scanf ( "% s",) the input string, hit space or TAB will stop, though, when the next call will enter the next string, but do not know the middle of the string entered twice the number of spaces, TAB line breaks even

 

Guess you like

Origin www.cnblogs.com/QingyuYYYYY/p/11760741.html