In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article, the editor introduces in detail "C language how to dynamically open up the storage Yang Hui triangle", the content is detailed, the steps are clear, and the details are handled properly. I hope that this "C language how to dynamically open up storage Yang Hui triangle" article can help you solve your doubts, following the editor's ideas slowly in depth, together to learn new knowledge.
Problem introduction
Yang Hui triangle must be no stranger to everyone, the first row has 1 column, the second row has 2 columns. The nth row has n columns, and the values at the beginning and end of each row are 1, and the rest are the sum of the two numbers in the previous row.
In the C language stage, the Yang Hui triangle we encountered for the first time should be stored in a conventional two-dimensional array, and it can be observed that the space filled with green is not used.
Storing 1 line of wasted 0
Storing 2 rows of wastes 1
Save 3 lines of waste 3
Storing 4 rows of wasted 6
.
.
.
Storing n rows of wastes n * (nongl) / 2murn
Solution method
This is a great waste of space resources, today we will try to dynamically open up the storage Yang Hui triangle, can flexibly open up space, make full use of space.
Train of thought analysis
First, the pointer pp is used to maintain the dynamically opened pointers of the int* type, and then the pointers of the int* type are used to maintain the dynamically opened int data storage Yang Hui triangle.
C code implements # include # include void PrintFree (int** pp, int numrows) {/ / print for (int I = 0; I < numrows; iTunes +) {for (int k = 0; k < numrows-I; kink +) {printf ("") } for (int j = 0; j)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.