Love丶FFC's Blog
给定n个正整数,找出它们中出现次数最多的数。如果这样的数有多个,请输出其中最小的一个。
输入的第一行只有一个正整数n(1 ≤ n ≤ 1000),表示数字的个数。
输入的第二行有n个整数s1, s2, …, sn (1 ≤ si ≤ 10000, 1 ≤ i ≤ n)。相邻的数用空格分隔。
输出这n个次数中出现次数最多的数。如果这样的数有多个,输出其中最小的一个。
6
10 1 10 20 30 20
10
1.先找出出现次数最多的数并存放。
2.再找出其中最小的数。
package CCF_CSP; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class _20131201_100point { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); //数字个数 int[] s = new int[n]; //存放整数的数组 int[] total = new int[n]; //存放各个整数的相同个数 for(int i=0;i<n;i++) { s[i]=scanner.nextInt(); for(int j=0;j<n;j++) { if(s[j]==s[i]) //存在相同的整数 { total[j]++; } } } int maxtotal=total[0]; //定义初始相同个数 for(int i=0;i<n;i++) { if(total[i]>maxtotal) //发现更大的相同个数 { maxtotal=total[i]; } } List<Integer> maxtotals = new ArrayList<Integer>(); int minnumber = 0; for(int i=0;i<n;i++) { if(total[i]==maxtotal) //发现最大相同个数对应的整数 { maxtotals.add(s[i]); //将该整数存放进泛型中 minnumber=s[i]; //定义该情况下的最小整数 } } for(int i=0;i<maxtotals.size();i++) { if(maxtotals.get(i)<minnumber) //发现该情况下的更小整数 { minnumber=maxtotals.get(i); } } System.out.println(minnumber); } }
Jorcift
cialis vs. viagra recreational use fluoxetine will increase the level or effect of mexiletine by affecting hepatic enzyme CYP2D6 metabolism
intuido
Sanchez Alcazar, J cialis buy
intuido
online pharmacy finax Lowering dietary saturated fat will help to restore fat balance and result in improvement of breast pain symptoms
EyeLit
cheap viagra without prescription
EyeLit
can i buy piroxicam over the counter
IvyLit
buy accutane online usa
JoeLit
generic viagra from canada
EyeLit
lavitra
EyeLit
lyrica online uk
MaryLit
amoxil medication
Williamjotly
zithromax pills
Elwoodexcix
buy lisinopril 10 mg uk
JackLit
azithromycin 500mg
IvyLit
atarax uk
fWgBMBB
Rohini, Delhi Shop No does ageless male work like viagra
EyeLit
phenergan tablets online uk
EyeLit
cafergot uk
EyeLit
medrol 16 mg 1mg
Michaelsmopy
buying valtrex in mexico
EyeLit
amoxicillin 500 mg brand name
AshLit
diclofenac cream
Elwoodexcix
where can i buy dapoxetine in south africa
EyeLit
erectafil 5mg
JackLit
biaxin 500
Williamjotly
cost of propecia
AshLit
triamterene/hctz 37.5
AlanLit
price of levaquin
DarrylBox
dexamethasone tablets uk
DarrylBox
prednisolone 4mg cost
IvyLit
buying azithromycin in mexico
Michaelsmopy
dexamethasone where to get
Elwoodexcix
levaquin 750mg
MaryLit
atarax tablet price
Richardatone
lipitor australia
JosephKip
baclofen 10 mg price in india
Michaelsmopy
levaquin 250
AlanLit
canadian prescription pharmacy
DarrylBox
online pharmacy
SamuelEcors
phenergan brand name
JosephKip
buy cymbalta online australia
SamuelEcors
obagi tretinoin cream
SamLit
phenergan generic otc cost
SueLit
atarax 10mg prescription
Richardatone
tamoxifen cost australia
IvyLit
levaquin buy
SamuelEcors
20 mg cymbalta daily
SamLit
robaxin price
SamLit
where can i buy prednisolone tablets
Davidevelf
triamterene hctz 37.5 25 mg cp
SamuelEcors
levaquin 750 mg
Michaelsmopy
triamterene-hctz 37.5-25 mg
JackLit
sky pharmacy
Michaelsmopy
atarax 50
Richardatone
lipitor online price
Davidevelf
atarax 10mg otc
JoeLit
lipitor online pharmacy
DarrylBox
order atarax online
IvyLit
cheapest pharmacy
Elwoodexcix
levaquin antibiotics
Elwoodexcix
prazosin for anxiety
ZakLit
prazosin 3 mg
IvyLit
phenergan 10mg uk
MaryLit
atarax generic cost
Michaelsmopy
cheapest generic lipitor
ZakLit
buy atarax australia
EyeLit
azithromycin for sale usa
SamLit
which online pharmacy is the best
DarrylBox
phenergan over the counter
Michaelsmopy
can i buy cymbalta online
DavisIgnip
cialis 5 mg price
AshLit
synthroid cost usa
DarrylBox
canadian pharmacy world
MaryLit
best price for cymbalta 60 mg
JackLit
cymbalta 30
DarrylBox
azithromycin australia over the counter
ZakLit
atarax over the counter uk
IvyLit
purchase levaquin
Richardatone
robaxin south africa
Elwoodexcix
how to get diflucan
DarrylBox
diflucan cost canada
EyeLit
legitimate online pharmacy uk
Elwoodexcix
diflucan 200 mg pill
MaryLit
where to get flomax
ZakLit
flomax tamsulosin
SamLit
zithromax antibiotic without prescription
EyeLit
prednisone 5mg
Davidevelf
generic for augmentin
Michaelsmopy
propecia tablets in india
IvyLit
synthroid 1 mg
JoeLit
buy fluconazol
SamuelEcors
flomax 2mg
Elwoodexcix
inderal without prescription
ZakLit
prednisone cream over the counter
ZakLit
diclofenac brand name
SamuelEcors
flomax 0.4mg
Richardatone
phenergan tablet cost
SamuelEcors
generic for zanaflex
JoeLit
synthroid capsules
SamLit
120 mg strattera
ZakLit
plavix generic canada
AlanLit
celebrex generic coupon
IvyLit
cost tizanidine
SamLit
cost of generic azithromycin
EyeLit
best price for celebrex
SamLit
retino 0.05 gel
EyeLit
buy prednisone online canada without prescription
JosephKip
order generic propecia online
CurtisHed
deltasone generic 5mg
DavisIgnip
tizanidine 4 mg price
JoeLit
how to get augmentin
ZakLit
where to buy voltaren gel
JackLit
synthroid 25 mcg daily
SamLit
tizanidine 5.2
AshLit
prednisone best price
Williamjotly
where can i buy albuterol
SamuelEcors
plavix medication price
MaryLit
suhagra 100 online purchase
CurtisHed
lyrica 25mg price
SamuelEcors
diclofenac misoprostol
Richardatone
doxycycline pharmacy singapore
SueLit
accutane india pharmacy
Richardatone
where to buy voltaren tablets
IvyLit
diflucan buy without prescription
Elwoodexcix
synthroid 15 mcg
ZakLit
diflucan 50 mg capsule
Elwoodexcix
amoxicillin 800 mg price
JoeLit
suhagra 50mg tablet online
Michaelsmopy
synthroid 137.5
Richardatone
buy voltaren gel in canada
AshLit
buy cephalexin 500mg online
JosephKip
amoxicillin 650 mg
Richardatone
diflucan drug coupon
Michaelsmopy
strattera for sale
DavisIgnip
retino a
JackLit
bactrim 800 mg pills