-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame (1).java
More file actions
56 lines (39 loc) · 1.23 KB
/
game (1).java
File metadata and controls
56 lines (39 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package game;
import java.util.*;
public class game {
private static class Node {
int data;
Node next;
public Node(int data) {
this.data = data;
this.next = null;
}
}
public static void balonPozisyonuBul(int m, int n) {
Node head = new Node(1);
Node current = head;
for (int i = 2; i <= n; i++) {
Node node = new Node(i);
current.next = node;
current = current.next;
}
current.next = head;
while (current.next != current) {
for (int i = 1; i < m; i++) {
current = current.next;
}
Node temp = current.next;
current.next = temp.next;
temp = null;
}
System.out.println("Son kalan balonun pozisyonu: " + current.data);
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("N değerini girin: ");
int n = scanner.nextInt();
System.out.print("M değerini girin: ");
int m = scanner.nextInt();
balonPozisyonuBul(m, n);
}
}