SHARE
TWEET

Untitled

a guest Feb 17th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package vk400;
  7.  
  8. import java.util.Arrays;
  9. import java.util.Scanner;
  10. import java.util.Stack;
  11. import java.util.concurrent.ThreadLocalRandom;
  12.  
  13. /**
  14.  *
  15.  * @author RedMagic-PC
  16.  */
  17. public class Vk400 {
  18.     static void stack_push(Stack<Integer> stack,int a)
  19.     {
  20.         stack.push(new Integer(a));
  21.     }
  22.      
  23.     static void stack_pop(Stack<Integer> stack,int sz)
  24.     {
  25.         System.out.println("Pop :");
  26.  
  27.         for(int i = 0; i < sz; i++)
  28.         {
  29.             Integer y = (Integer) stack.pop();
  30.             System.out.println(y);
  31.         }
  32.     }
  33.     static void stack_read(Stack<Integer> stack,int sz)
  34.     {
  35.         System.out.println(Arrays.toString(stack.toArray()));
  36.     }
  37.     static int getRand(){
  38.         return ThreadLocalRandom.current().nextInt(1, 10 + 1);
  39.     }
  40.  
  41.     public static void main (String[] args)
  42.     {
  43.         Scanner sc = new Scanner(System.in);
  44.         Stack<Integer> stack = new Stack<Integer>();
  45.        
  46.         int chc=1;
  47.         int gss,cr;
  48.         int[] arr = new int[5];
  49.         while(chc==1){
  50.             for(int i=1;i<=5;i++){
  51.                 System.out.print( i + ". Guess : ");
  52.                 gss = sc.nextInt();
  53.                 arr[i-1] =  getRand();
  54.                 if(gss==arr[i-1]){
  55.                     stack_push(stack,gss);
  56.                    
  57.                 }
  58.             }
  59.             System.out.println("Correct guesses : " + stack.size());
  60.             System.out.println("Wrong Guesses   : " + (5-stack.size()));
  61.             System.out.print("Again ? 1/0     : ");
  62.             chc = sc.nextInt();
  63.         }
  64.     }
  65. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top