NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package st;
import java.util.*;
import java.util.Scanner;
public class Soru2
{

public static void main(String[] args)
{
int n;
int n2 = 0;
int n3 = 0;
int n4 = 0;
int n5 = 0;
int n6 = 0;
int n7 = 0;
int n8 = 0;
boolean bl = false;
boolean bl2 = false;
int n9 = 0;
int n10 = 100;
Scanner scanner = new Scanner(System.in);
System.out.println("Enter dimension D to create DxD matrix: ");
n2 = scanner.nextInt();
scanner.nextLine();
n3 = (int)Math.sqrt(n2);
int n11 = n2 - 1;
int n12 = ++n3 - 1;
Random random = new Random();
int n13 = random.nextInt(n11 - n12 + 1) + n12;
int n14 = random.nextInt(n11 - n12 + 1) + n12;
n8 = n13 + n14;
System.out.println("Dimension: " + n2 + "x" + n2);
System.out.println("Cheats left: " + n3);
boolean bl3 = false;
while (n6 != n13 || n7 != n14) {
System.out.println("You're at (" + n6 + "," + n7 + ")");
for (int i = 0; i < n2; ++i) {
for (n = 0; n < n2; ++n) {
if (i == n6 && n == n7) {
System.out.print("O ");
continue;
}
System.out.print("* ");
}
System.out.println();
}
System.out.println("Enter your choice (a:left,d:right,w:up,s:down) :");
String string = scanner.nextLine();
if (string.length() > 0) {
n10 = string.charAt(0);
}
switch (n10) {
case 87:
case 119: {
if (n6 - 1 >= 0) {
--n6;
} else {
System.out.println("Can't go up!.");
}
++n9;
break;
}
case 83:
case 115: {
if (n6 + 1 < n2) {
++n6;
} else {
System.out.println("Can't go down!.");
}
++n9;
break;
}
case 65:
case 97: {
if (n7 - 1 >= 0) {
--n7;
} else {
System.out.println("Can't go left!.");
}
++n9;
break;
}
case 68:
case 100: {
if (n7 + 1 < n2) {
++n7;
} else {
System.out.println("Can't go right!.");
}
++n9;
break;
}
case 67:
case 99: {
if (n3 > 0) {
n = Math.abs(n6 - n13) + Math.abs(n7 - n14);
System.out.println("You're " + n + " moves away from Waldo.");
System.out.println("You have " + --n3 + " cheats left.");
break;
}
System.out.println("You have no cheats left!");
break;
}
default: {
System.out.println("Incorrect move!");
}
}
if (bl3) {
n4 = n6;
n5 = n7;
bl3 = false;
continue;
}
bl3 = true;
}
for (int i = 0; i < n2; ++i) {
for (n = 0; n < n2; ++n) {
if (i == n6 && n == n7) {
System.out.print("O ");
continue;
}
System.out.print("* ");
}
System.out.println();
}
System.out.println("Congrats! You found Waldo at (" + n6 + "," + n7 + ")");
System.out.println("Minimum of possible movements was " + n8 + ".");
System.out.println("You moved " + n9 + " times.");
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.