most of 1-1000
来源:互联网 发布:november rain 知乎 编辑:程序博客网 时间:2024/06/04 19:49
#define _CRT_SECURE_NO_WARNINGS#include<iostream>using namespace std;void search(int arr[] ,int len) { int a[100] = {0}; int max = 0; for (int i = 0; i < len; i++) { int index = arr[i] - 1; a[index]++; } for (int i = 0; i < 100; i++) { if (a[i]>max) max = a[i]; } cout << max<< endl; //最多次数 for (int i = 0; i < 99; i++) { if (max == a[i]) cout << i + 1; //最多的数 }}int main() { //求1-100数列中出现最多的数及次数 int arr[] = { 1, 55, 4, 4 ,9,9,9,9}; search(arr, sizeof(arr)/sizeof(arr[0])); system("pause"); return 0;}
package pack;public class Main { public static void main(String[] args) { int[] arr = { 1, 3, 5, 6, 7, 8, 3, 4, 3 ,3}; search(arr, arr.length); } public static void search(int[] arr, int len) { int max = 0; int[] a = new int[100]; for (int i = 0; i < len; i++) { int index = arr[i]; a[index-1]++; } for(int i = 0;i<100;i++) { if(max<a[i]) max = a[i]; } System.out.println(max); for(int i = 0;i<100;i++) { if(a[i]==max) System.out.println(i+1); } }}
0 0
- most of 1-1000
- Most Simple Usage Of Tensorboard
- The most important rules of writing paper
- 50 of the most important python module
- Getting the most out of IDispatch(XYDispDriver)
- The most important part of the body
- Some of the most common web site
- Make the most of your 20s
- the most right digit of N^N.
- The most important state of mind
- The most common (worst) passwords of 201
- The most popular color of balloon
- vim most powerful, not one of
- MOST
- most
- List of the Most Common Data Type Mappings
- Tweaking your system to get the most out of BitTorrent
- Morgan Fairchild Makes the Most of It With 'The Graduate'
- 第4周—项目3.(1)结点逆置
- 卡尔曼滤波算法实例剖析--机器人足球赛场中的定位算法
- 归并排序
- iOS开发 ----- Controller之间的传值
- Java教程开山篇—开发环境搭建
- most of 1-1000
- nginx学习
- PHP无限分类的原理
- Android读写操作之内存的读写操作
- google adsense初次申请后广告无法显示问题
- LightOJ 1030 Discovering Gold 概率
- iOS通过UIAlertView实现Android Toast效果
- hdu 2452 Navy maneuvers-记忆化搜索
- css中的优先级