One: "+ +", "--" operation in the judgment and other statements directly used will reduce the code length: Example 1: The following squeeze (s,c) function, which deletes the string s appears to be all characters c:void squeeze (char s[],int c) {int i,j; for (i=j=0;s[i]! = ' s[i '; i++) {if (s[i]! = c) {s[j++] =); }} S[j] = ' + ';}
Where the If statement is simplified by the following if statement: if (s[i]! = c) {S[j] = s[i]; j + +;}
Three: Define # define with a macro: #define MAX (A, B) ((a) > A):(B)); #define MIN (a) (a) < (b) ( A):(B)); This reduces the amount of time the program runs by eliminating the need to use functions to implement max,min, reducing the CPU used to invoke functions. Four: Perform operations in return without extra code in the body of the function, making the code look simpler! The example will not be used, ha.
This article is from "Narcissus" blog, please make sure to keep this source http://10704527.blog.51cto.com/10694527/1704937
Some shorthand code methods