Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Random;
- public class sequTest{
- public static void main (String[] args){
- Random rand = new Random();
- int n [] = new int[1000000000];
- for (int x =0;x<n.length;x++){
- n[x]=rand.nextInt(129) + 1;
- }
- Scanner input = new Scanner(System.in);
- int count =0;
- int x = input.nextInt();
- boolean found=false;
- int searches=0;
- for (int i=0; i<n.length; i++) {
- searches+=1;
- if (n[i]==x){
- found=true;
- count+=1;
- }
- }
- if (found==true){
- System.out.println(x+"found "+count+"times");
- }
- System.out.println("searches"+searches);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement