Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.util.Scanner;
- public class Excise2801 {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- Random r = new Random();
- System.out.print("x: ");
- int x = in.nextInt();
- System.out.print("y: ");
- int y = in.nextInt();
- System.out.print("n: ");
- int n = in.nextInt();
- String[][] xy = new String[x][y];
- for (int i = 0; i < x; i++)
- for (int j = 0; j < y; j++)
- xy[i][j] = "-";
- for (; n > 0; n--)
- xy[r.nextInt(x)][r.nextInt(y)] = "*";
- for (int i = 0; i < x; i++) {
- for (int j = 0; j < y; j++)
- System.out.print(xy[i][j]);
- System.out.println();
- }
- int point = 0;
- while (true) {
- System.out.print("X: ");
- int X = in.nextInt();
- if (X < 0 || X >= x) continue;
- System.out.print("Y: ");
- int Y = in.nextInt();
- if (Y < 0 || Y >= y) continue;
- if (xy[X][Y] == "*") break;
- point += 10;
- }
- in.close();
- System.out.println("Score: " + point);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement