One week learning content summary

This week the main practiced pta set of topics, in practice the process, learn to think of some clever algorithms.

1.b[j]=sum%10;

     sum=sum/10;

Two lines of code can be determined a respective integer number of digits.

2.string is in accordance with the type of character to store data, so the numeric character you want to calculate the time according to the type of input string, you need to enter the number zero minus character is a figure corresponding to the real.

3. When it is desired to calculate the time before data classification, different types of data may be numbered, and then to an array subscript. E.g:

scanf("%d%d", &idx, &x);

a[idx] += x;

The two lines of code for each data set id subscript of an array, and then adding the same array subscript x.

4. When the input data is particularly large, should be set to a long type or character type, the case to avoid the occurrence of insufficient memory.

5.

while(cin>>k>>j)

This line means that determines whether the correct input stream, the input data type is correct, the execution cycle, incorrect loop is exited.

6. use getchar, on the keyboard and press a character, press Return to read into it; when used getch, according to a character on the keyboard soon be read into it, do not press Enter, and therefore can be used as "press any key to continue "executing the statement. getchar () reads a character you can only exit when reading a carriage return.

Guess you like

Origin www.cnblogs.com/wangzhaojun1670/p/11367339.html