forked from MiYazJE/Acepta-el-reto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p173.java
59 lines (44 loc) · 1.38 KB
/
p173.java
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
54
55
56
57
58
59
import java.util.*;
/**
* @author Rubén Saiz
* 18/07/2019
*/
public class p173 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
char[] puntos;
int pA, pB;
char saca;
boolean espacio, imprimir;
while (true) {
puntos = s.next().toCharArray();
if (puntos[0] == 'F') break;
saca = 'A';
pA = 0; pB = 0;
espacio = false;
imprimir = true;
for (int i = 0; i < puntos.length; i++) {
if (puntos[i] == 'F' && imprimir) {
if (espacio) System.out.print(" ");
System.out.print(pA + "-" + pB);
break;
} else imprimir = true;
if (puntos[i] == 'A') {
if (saca == 'A') pA++;
else saca = 'A';
}
else {
if (saca == 'B') pB++;
else saca = 'B';
}
if ((pA > 8 || pB > 8) && (Math.abs(pA - pB) > 1) ) {
if (espacio) System.out.print(" ");
System.out.print(pA + "-" + pB);
pA = pB = 0;
espacio = true; imprimir = false;
}
}
System.out.println();
}
}
}