pat 1054
PAT
2023-09-14 09:13:21 时间
1、题目链接
https://www.patest.cn/contests/pat-a-practise/1054
2、题意分析
(1)题意:找出矩阵中出现次数最多的数
(2)分析:预处理即可。
3、源代码
#include <stdio.h>
#define size 100000000
long long array[size];
int main(){
int m,n;//矩阵的m列,n行
long long number;
long long max = 0;
scanf("%d %d", &m,&n);
for(int i = 0;i<n;i++){
for(int j = 0;j<m;j++){
scanf("%lld",&number);
array[number]++;
if(max < number){
max = number;
}
}
}
long long maxCount = 0;
for(int i = 0;i <= max;i++){
if(array[maxCount] < array[i])
maxCount = i;
}
printf("%d\n",maxCount);
}
/*
5 3
0 0 255 16777215 24
24 24 0 0 24
24 0 24 24 24
1 1
1
*/
相关文章
- 1009 说反话 (20 分)—PAT (Basic Level) Practice (中文)
- PAT A 1065. A+B and C (64bit) (20)
- PAT 1039 Course List for Student[难]
- PAT 1145 Hashing - Average Search Time [hash][难]
- PAT 1110 Complete Binary Tree[判断完全二叉树]
- PAT 1129 Recommendation System[比较]
- PAT 1068 Find More Coins[dp][难]
- PAT 1027 Colors in Mars[简单][注意]
- PAT 1044
- pat 1090
- Pat 1020
- PAT 1135 Is It A Red-Black Tree 【C++版】
- PAT 1109 Group Photo [Java]
- PAT 1022 D进制的A+B (20 分)