Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // OJO: Este archivo no pertenece a ningún paquete (package)
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- /**
- * Calcula la cantidad y la suma de numeros pares en una lista de numeros
- * @author Rodrigo Cardoso
- */
- public class ProblemaZ_rc {
- public static int np; // No. de datos pares
- public static int snp; // Suma de datos pares
- public static void main(String[] args) throws IOException {
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- String lineain,data[];
- while (true){ // Ciclo hasta que haya datos
- lineain = br.readLine();
- if (lineain.isEmpty()) return;
- data = lineain.split(" ");
- np = 0;
- snp = 0;
- for (int i=0; i!=data.length; i++){
- int z = Integer.parseInt(data[i]);
- if (z % 2 == 0){
- np++;
- snp += z;
- }
- }
- System.out.println(np + " " + snp);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement