当前位置:网站首页>2021-08-11 function pointer
2021-08-11 function pointer
2022-07-04 09:47:00 【skeet follower】
Young's matrix
There is a matrix of numbers , Each row of the matrix is incremented from left to right , The matrix is increasing from top to bottom , Please write a program to find out whether a number exists in such a matrix .
requirement : Time complexity is less than O(N);
#include<stdio.h>
void find_k(int a[3][3], int k, int x, int y)
{
// According to the characteristics of matrix increment , Starting from the upper right corner, the time complexity will be relatively small ;
int n= 0;
int m = y - 1;
// Abscissa cannot be greater than 3, The ordinate should be greater than or equal to 0;
while (n < x && m >= 0) {
// If smaller , Abscissa plus
if (a[n][m] < k) {
n++;
}
// If it's bigger , Minus ordinate
else if (a[n][m] > k) {
m--;
}
else {
printf(" Found the subscript is :%d %d", n, m);
return;
}
}
printf(" Can't find \n");
}
int main()
{
int k = 17;
int a[3][3] = { 1,2,3,4,5,6,7,8,9 };
find_k(a,k,3,3);
return 0;
}
边栏推荐
- Hands on deep learning (46) -- attention mechanism
- 智能网关助力提高工业数据采集和利用
- Qtreeview+ custom model implementation example
- C # use gdi+ to add text to the picture and make the text adaptive to the rectangular area
- Analysis report on the development status and investment planning of China's modular power supply industry Ⓠ 2022 ~ 2028
- ASP. Net to access directory files outside the project website
- Hands on deep learning (42) -- bi-directional recurrent neural network (BI RNN)
- Nuxt reports an error: render function or template not defined in component: anonymous
- 2022-2028 global seeder industry research and trend analysis report
- 百度研发三面惨遭滑铁卢:面试官一套组合拳让我当场懵逼
猜你喜欢
Hands on deep learning (46) -- attention mechanism
PHP personal album management system source code, realizes album classification and album grouping, as well as album image management. The database adopts Mysql to realize the login and registration f
智能网关助力提高工业数据采集和利用
pcl::fromROSMsg报警告Failed to find match for field ‘intensity‘.
回复评论的sql
C语言指针面试题——第二弹
Hands on deep learning (43) -- machine translation and its data construction
PHP book borrowing management system, with complete functions, supports user foreground management and background management, and supports the latest version of PHP 7 x. Database mysql
xxl-job惊艳的设计,怎能叫人不爱
2022-2028 global intelligent interactive tablet industry research and trend analysis report
随机推荐
Hands on deep learning (32) -- fully connected convolutional neural network FCN
百度研发三面惨遭滑铁卢:面试官一套组合拳让我当场懵逼
El Table Radio select and hide the select all box
MATLAB小技巧(25)竞争神经网络与SOM神经网络
Global and Chinese market of planar waveguide optical splitter 2022-2028: Research Report on technology, participants, trends, market size and share
Hands on deep learning (33) -- style transfer
How do microservices aggregate API documents? This wave of show~
Hands on deep learning (40) -- short and long term memory network (LSTM)
Leetcode (Sword finger offer) - 35 Replication of complex linked list
Regular expression (I)
Machine learning -- neural network (IV): BP neural network
C语言指针面试题——第二弹
Get the source code in the mask with the help of shims
Ultimate bug finding method - two points
查看CSDN个人资源下载明细
2022-2028 global visual quality analyzer industry research and trend analysis report
Hands on deep learning (III) -- Torch Operation (sorting out documents in detail)
Implementing expired localstorage cache with lazy deletion and scheduled deletion
Fatal error in golang: concurrent map writes
2022-2028 global edible probiotic raw material industry research and trend analysis report