-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDN05.java
More file actions
39 lines (36 loc) · 1.18 KB
/
Copy pathDN05.java
File metadata and controls
39 lines (36 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
public class DN05 {
public static void main(String[] args) {
int[] tabela = new int[10];
String beseda = "";
for (int i = 0; i < args.length; i++) {
if (i==0){
beseda= args[i];
}
else {
beseda = beseda + " " + args[i];
}
}
for (int j = 0; j < beseda.length(); j++) {
if (Character.isDigit(beseda.charAt(j))){
tabela[Character.getNumericValue(beseda.charAt(j))]++;
}
}
int maxVrednost= 0;
String najpogostejse = "";
for (int k = 0; k < tabela.length; k++) {
if(tabela[k]>maxVrednost){
maxVrednost = tabela[k];
najpogostejse = k + " ";
}
else if (tabela[k]==maxVrednost){
najpogostejse = najpogostejse + k + " ";
}
}
if (maxVrednost==0){
System.out.println("V nizu '" + beseda + "' ni stevk");
}
else if (maxVrednost>0){
System.out.println("'"+beseda+"' -> "+ najpogostejse + "("+maxVrednost+")");
}
}
}