Created
July 28, 2016 16:14
-
-
Save totynho/c6f597e71c089a7f4d1635d2ec6b5e33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package javaapplication2; | |
import java.util.Scanner; | |
public class JavaApplication2 { | |
public static void main(String[] args) { | |
Scanner entrada = new Scanner(System.in); | |
int N=1 , K=1; | |
while(N != 0 && K != 0){ | |
N = entrada.nextInt(); | |
K = entrada.nextInt(); | |
while(N< 1 && N > 1000 && K < 1 && K > 100){ | |
N = entrada.nextInt(); | |
K = entrada.nextInt(); | |
} | |
int P[] = new int[N]; | |
for (int i = 0; i< N; i++){ | |
P[i] = entrada.nextInt(); | |
} | |
int check = 1; | |
int checkNumber = 0; | |
for (int i = 0; i< N; i++){ | |
int lcheck = 0; | |
for (int j = 0; j< N; j++){ | |
if (P[i] == P[j]){ | |
lcheck++; | |
} | |
} | |
if (lcheck >= K){ | |
check = lcheck; | |
checkNumber = P[i]; | |
} | |
} | |
if (N != 0 && K != 0){ | |
System.out.println(checkNumber); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment