Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.util.Scanner;
- public class App{
- public static void main(String []args){
- Random rand = new Random();
- Scanner sc = new Scanner(System.in);
- int[] nums = {0,0,0,0,0,0};
- for(int i=0;i<6;i++){
- boolean hasRepeated = false;
- int n;
- do{
- hasRepeated = false;
- n=rand.nextInt(49);
- n++;
- for(int j=0;j<6;j++){
- if(nums[j]==n){
- hasRepeated = true;
- }
- }
- } while(hasRepeated);
- nums[i]=n;
- }
- int[] choices = {0,0,0,0,0,0};
- for(int i=0;i<6;i++){
- int n;
- boolean hasRepeated=false;
- do{
- System.out.print("Vuvedete unikalno chislo nomer "+(i+1)+" (ot 1 do 49): ");
- n= sc.nextInt();
- hasRepeated = false;
- for(int j=0;j<6;j++){
- if(choices[j]==n){
- hasRepeated=true;
- }
- }
- } while(n<1 || n>49 || hasRepeated);
- choices[i] = n;
- }
- int matches = 0;
- for(int i=0;i<6;i++){
- for(int j=0;j<6;j++){
- if(nums[i]==choices[j]){
- matches++;
- continue;
- }
- }
- }
- System.out.println();
- if(matches>2){
- System.out.println("Pozdravleniq! Imate "+matches+" ucepeni chisla!");
- } else {
- System.out.println("Za sujalenie ne pechelite nishto");
- }
- }
- }
Add Comment
Please, Sign In to add comment