Jingle Composing

= Análisis =

= Solución =

C++
/** * Autores :           Juan Pablo Sandoval *                    Rodrigo Claros * * Fecha Publicacion:  9-nov-2009 *  * Muy facil **/ int main{ getchar; char c= getchar; while(c!='*'){ int buenas =0; while(c != '\n'){ int acum = 0; while(c>'A' && c<'Z'){ switch(c){ case 'W': acum+=64; break; case 'H': acum+=32; break; case 'Q': acum+=16; break; case 'E': acum+=8; break; case 'S': acum+=4; break; case 'T': acum+=2; break; case 'X': acum+=1; break; }                c = getchar; }            if(acum == 64) buenas+=1; c = getchar; }        printf("%d\n",buenas); c = getchar=='/'?getchar:'*'; } }
 * 1) include 

Java
import java.io.*;

import java.util.Scanner;

/**




 * @author Gekko



public class Tarea {

static double W=1;

static double H=0.5;

static double Q=0.25;

static double E=0.125;

static double S=0.0625;

static double T=0.03125;

static double X=0.15625;

static int contH;

static int contW;

static int contQ;

static int contE;

static int contS;

static int contT;

static int contX;

static double suma;

static int contCorrecto;

private static String sCadena;

public static void main(String[] args) throws FileNotFoundException, IOException {

BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

while ((sCadena = bf.readLine)!=null) {

String input = sCadena;

Scanner s = new Scanner(input).useDelimiter("\\/");

while(s.hasNext){

String input2 = s.next;

for(int i=0;i<input2.length;i++){

if(input2.charAt(i)=='*'){

System.exit(0);

}

if(input2.charAt(i)=='H'){

contH++;

}

if(input2.charAt(i)=='W'){

contW++;

}

if(input2.charAt(i)=='Q'){

contQ++;

}

if(input2.charAt(i)=='S'){

contS++;

}

if(input2.charAt(i)=='T'){

contT++;

}if(input2.charAt(i)=='E'){

contE++;

}

if(input2.charAt(i)=='X'){

contX++;

}

}

suma=H*contH+Q*contQ+S*contS+T*contT+E*contE+X*contX+W*contW;

if(suma==1){

contCorrecto++;

}

contH=0;

contW=0;

contQ=0;

contS=0;

contT=0;

contE=0;

contX=0;

}

System.out.println(contCorrecto);

contCorrecto=0;

}

}

}

=Disponible en=