* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pkg1585uva;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner entrada = new Scanner(System.in);
int suma = 0, sumatotal = 0, casos, cont = 0;
String cadena;
System.out.println("Introduce los numeros de casos");
casos = entrada.nextInt();
do {
cadena = entrada.next();
cont++;
for (int i = 0; i < cadena.length(); i++) {
if (cadena.charAt(i) == 'O') {
suma++;
sumatotal = sumatotal + suma;
} else if (cadena.charAt(i) == 'X') {
suma = 0;
}
}
System.out.println(sumatotal);
sumatotal = 0;
} while (casos != cont);
}
}
Solucionado por Jesús
Enlace de referencia: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4460
No hay comentarios:
Publicar un comentario