In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "what is the method of quickly getting started with Young's matrix algorithm in C language programming problem". In daily operation, I believe that many people have doubts about the method of fast use of Young's matrix algorithm in C language programming problem. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to solve the question of "what is the way to quickly get started with Yang's matrix algorithm in C language programming problem?" Next, please follow the editor to study!
Catalogue
Summary of the topic
First, the way to solve the problem
II. Specific codes
Summary of the topic
There is a numerical matrix in which each row of the matrix is incremented from left to right and the matrix is incremented from top to bottom. Please write a program to find out if a number exists in such a matrix.
First, the way to solve the problem
To find out whether the elements in an array exist, the first idea of many students is to go through them from beginning to end. The advantage of this idea is that the code is simple and brainless and easy to use, but this disadvantage is also obvious, such as m * n array, you go through it from beginning to end, and you have to find m * n times in the worst case. The relevant conditions given by the topic, such as increasing from left to right, and increasing from top to bottom, you do not use at all, such a violent solution is obviously not what we want to see.
Let's introduce a method, using the following two-dimensional array as an example
1 2 3
4 5 6
7 8 9
According to the fact that each row of the matrix is incremented from left to right, we know that the last number of each row of the matrix is the largest in the row, such as the matrix above. As to whether 7 is in this matrix, we can compare with the last number of each row, if 7 is less than the current row, then traverse in the current row, otherwise compare with the last number of the next row. If the last row is less than 7, 7 is not in the matrix.
II. Specific codes
The code is as follows (example):
# includevoid find (int arr [3] [3], int kjinint htraining int l) / / h and l denote the row and column {int x = 0 int / first row Abscissa int y = l-1 X / first row last row ordinate for (x = 0r [x] [y] < karmacx) respectively
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.