当前位置:网站首页>Lucky numbers in the matrix
Lucky numbers in the matrix
2022-06-26 14:09:00 【fe11953264】
subject
To give you one m * n Matrix , The number in the matrix Each are not identical . Please press arbitrarily Return all the lucky numbers in the matrix in order .
Lucky number refers to the elements in the matrix that meet the following two conditions at the same time :
The smallest of all elements in the same row
The largest of all elements in the same column
break And continue Comparison of
break You can only jump out of a loop . When there are multiple nested loops ,break Can only jump out of “ The parcel ” Its innermost layer of circulation , Can't jump out of all loops at once .
continue It's very simple , Its function is to end this cycle , That is, skip the following unexecuted statements in the loop body , Then, it is determined whether to execute the cycle next time .
Code
int* luckyNumbers (int** matrix, int matrixSize, int* matrixColSize, int* returnSize){
int *adc=(int*)malloc(sizeof(int) * matrixSize * matrixColSize[0]);
int shu = 0;
for(int i = 0 ; i < matrixSize ; i++){
for(int y = 0 ; y < matrixColSize[0] ; y++){
bool max1 = true , min1 = true;
for(int k = 0 ; k < matrixColSize[0] ; k++){ // The smallest... In the column
if(matrix[i][k] < matrix[i][y]){
min1 = false;
break;
}
}
if(!min1){ // Wrong column , Return to find a new value
continue;
}
for(int n = 0 ; n < matrixSize ; n++){ // Maximum in row
if(matrix[n][y] > matrix[i][y]){
max1 = false;
break;
}
}
if(max1){
adc[shu++] =matrix[i][y];
}
}
}
*returnSize = shu;
return adc;
}
边栏推荐
- Basic type of typescript
- d检查类型是指针
- Wechat applet -picker component is repackaged and the disabled attribute is added -- above
- 永远不要使用Redis过期监听实现定时任务!
- CF676C Vasya and String
- 使用 Performance 看看浏览器在做什么
- CVPR 2022文档图像分析与识别相关论文26篇汇集简介
- Logical operation
- Pointer
- 基于PyTorch的生成对抗网络实战(7)——利用Pytorch搭建SGAN(Semi-Supervised GAN)生成手写数字并分类
猜你喜欢
9 articles, 6 interdits! Le Ministère de l'éducation et le Ministère de la gestion des urgences publient et publient conjointement neuf règlements sur la gestion de la sécurité incendie dans les établ
9 regulations and 6 prohibitions! The Ministry of education and the emergency management department jointly issued the nine provisions on fire safety management of off campus training institutions
A must for programmers, an artifact utools that can improve your work efficiency n times
Installation and uninstallation of MySQL software for windows
Es sauvegarde et restauration des données par instantané
Gartner 2022年顶级战略技术趋势报告
Zero basics of C language lesson 8: Functions
Wechat applet magic bug - choose to replace the token instead of clearing the token, wx Getstoragesync will take the old token value instead of the new token value
Win10 home vs pro vs enterprise vs enterprise LTSC
Logical operation
随机推荐
[MySQL from introduction to mastery] [advanced part] (II) representation of MySQL directory structure and tables in the file system
免费的机器学习数据集网站(6300+数据集)
Self created notes (unique in the whole network, continuously updated)
2021-10-18 character array
去某东面试遇到并发编程问题:如何安全地中断一个正在运行的线程
[sdoi2013] forest
古瑞瓦特沖刺港交所上市:創下“多個第一”,獲IDG資本9億元投資
Is expression of D
Codeforces Global Round 21A~D
永远不要使用Redis过期监听实现定时任务!
Linear basis
Bug STL string
[scoi2016] lucky numbers
Sed editor
On insect classes and objects
Calculate the distance between two points (2D, 3D)
Lamp compilation and installation
Es common grammar I
Network remote access using raspberry pie
It is better and safer to choose which securities company to open an account for flush stock