全部博文(136)
分类: C/C++
2011-03-15 08:53:39
In the end, only familiarity with the tools and techniques of the field will provide the right solution for a particular problem, and only a certain amount of experience will provide consistently professional results.
Raymond Fielding. The Technique of Special Effects Cinematography
of computer science, a rich field of elegant techniques and sophisticated mathematical analyses.
probme in seconds that could otherwise take years.
others have already done well.
choose among alternatives.
every program — primarily searching and sorting — and even those after often included in libraries. Similarly, almost every data structure is derived from a few fundamental ones.
Nothing beasts an array for storing static tabular data. Compile-time initialization makes it cheap and easy to construct such arrays. In a program to detet words that are used rather too much in bad prose, we can write
The search routing needs to know how many elements are in the array. One way to tell it is to pass the length as an argument; another, used here, is to place a NULL marker at the end of the array:
In C and C++, a parameter that is an array of strings can be declared as char *array[] or char **array. Although these forms are equivalent, the first makes it clearer how the parameter will be used.
Here's an excerpt from an array of more realistic size from a program that parses HTML, which defines textual names for well over a hundred individual characters:
to find the array index of the character 1/2.
Beyond some size of input (which varies with the implementation), binary search is faster than linear search.