arrow_forward همه ارسال‌ها

جزئیات ارسال کد#990

verified
وضعیت داوری نهایی: خطای کامپایل مشاهده لاگ خطا
terminal
زبان برنامه‌نویسی: Java
schedule
ارسال‌کننده و زمان:
khashayar moeinfar (۵ ماه پیش)
descriptionMain.java ۳۵ خط • ۷۷۱ بایت
1import java.util.*
2class Main {
3
4 public static void main(String[] args) {
5
6 Scanner sc = new Scanner(System.in);
7
8 int n = sc.nextInt();
9 int p = sc.nextInt();
10
11 int[] position = new int[]{
12 sc.nextInt(),
13 sc.nextInt()
14 };
15 sc.nextLine();
16
17 String s = sc.nextLine();
18
19 int[] direction = new int[]{
20 p * ((s.contains("E") ? 1 : 0) - (s.contains("W") ? 1 : 0)),
21 p * ((s.contains("S") ? 1 : 0) - (s.contains("N") ? 1 : 0))
22 };
23
24
25 for (int i = 0; i < 2; i++) {
26 position[i] = (((position[i] + direction[i]) % n)+n)%n;
27 }
28
29 System.out.println(Arrays.toString(position));
30
31
32 }
33
34
35}
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8