Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package vk400;
- import java.util.Arrays;
- import java.util.Scanner;
- import java.util.Stack;
- import java.util.concurrent.ThreadLocalRandom;
- /**
- *
- * @author RedMagic-PC
- */
- public class Vk400 {
- static void stack_push(Stack<Integer> stack,int a)
- {
- stack.push(new Integer(a));
- }
- static void stack_pop(Stack<Integer> stack,int sz)
- {
- System.out.println("Pop :");
- for(int i = 0; i < sz; i++)
- {
- Integer y = (Integer) stack.pop();
- System.out.println(y);
- }
- }
- static void stack_read(Stack<Integer> stack,int sz)
- {
- System.out.println(Arrays.toString(stack.toArray()));
- }
- static int getRand(){
- return ThreadLocalRandom.current().nextInt(1, 10 + 1);
- }
- public static void main (String[] args)
- {
- Scanner sc = new Scanner(System.in);
- Stack<Integer> stack = new Stack<Integer>();
- int chc=1;
- int gss,cr;
- int[] arr = new int[5];
- while(chc==1){
- for(int i=1;i<=5;i++){
- System.out.print( i + ". Guess : ");
- gss = sc.nextInt();
- arr[i-1] = getRand();
- if(gss==arr[i-1]){
- stack_push(stack,gss);
- }
- }
- System.out.println("Correct guesses : " + stack.size());
- System.out.println("Wrong Guesses : " + (5-stack.size()));
- System.out.print("Again ? 1/0 : ");
- chc = sc.nextInt();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement