miércoles, 21 de enero de 2015

Solucion 1585 Puntuacion

/*
 * 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 UVA;

import java.util.Scanner;

/**
 *
 * @author dam116
 */
public class UVA1585_Puntuacion {

    public static void main(String[] args) {
        Scanner entrada = new Scanner(System.in);
        String cadena;
        int valor = 1, num, nota = 0;
        num = entrada.nextInt();
        for (int i = 0; i < num; i++) {
            cadena = entrada.next();
            for (int j = 0; j < cadena.length(); j++) {
                if (cadena.charAt(j) == 'O') {
                    nota += valor;
                    valor++;
                }else{
                    valor = 1;
                }
            }
            System.out.println(nota);
            nota = 0;
            valor = 1;
        }
    }
}
Solucionado por Santiago y Amanda

No hay comentarios:

Publicar un comentario