1 条题解
-
0
C++ :
#include <iostream> using namespace std; int main(){ int x,r[110] = {0},ma,n,i; cin>>n; for(i = 0;i < n;i++){ cin>>x; r[x]++; } ma = 1; //排序 for(i = 1;i <= 100;i++){ if(r[i] >= r[ma]){ ma = i; } } cout<<ma<<endl; }
Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int m = sc.nextInt(); int[] a = new int[100]; int j = 0; int p = 0; for(int i = 0 ; i < m ; i++) { int x = sc.nextInt(); if(a[x] == 0) ++j; a[x]++; } int max = a[0]; for(int i = 1 ; i < 100 ; i++){ if(a[i]>=max) {max = a[i];p = i;} } System.out.println(p); } }
Python :
n=int(input()) a=input().split() a=list(map(int,a)) da=0 k=0 for i in range(100,0,-1): if(a.count(i)>da): da=a.count(i) k=i print(k)
- 1
信息
- ID
- 2418
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者