█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 4435

Problema 0x78 - Suma de 2 números

  • Autor: sergio95it
  • Fecha: 2021-06-20 23:17:43 UTC (Hace casi 3 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      Main.java:7: error: incompatible types: String[] cannot be converted to String
    String numeros = input.split("\\s+");
                                ^
Main.java:8: error: array required, but String found
    int a = Integer.parseInt(numeros[0]);
                                    ^
Main.java:9: error: array required, but String found
    int b = Integer.parseInt(numeros[1]); 
                                    ^
3 errors

                    
#2
Error de compilación
                      Main.java:7: error: incompatible types: String[] cannot be converted to String
    String numeros = input.split("\\s+");
                                ^
Main.java:8: error: array required, but String found
    int a = Integer.parseInt(numeros[0]);
                                    ^
Main.java:9: error: array required, but String found
    int b = Integer.parseInt(numeros[1]); 
                                    ^
3 errors

                    
#3
Error de compilación
                      Main.java:7: error: incompatible types: String[] cannot be converted to String
    String numeros = input.split("\\s+");
                                ^
Main.java:8: error: array required, but String found
    int a = Integer.parseInt(numeros[0]);
                                    ^
Main.java:9: error: array required, but String found
    int b = Integer.parseInt(numeros[1]); 
                                    ^
3 errors

                    
#4
Error de compilación
                      Main.java:7: error: incompatible types: String[] cannot be converted to String
    String numeros = input.split("\\s+");
                                ^
Main.java:8: error: array required, but String found
    int a = Integer.parseInt(numeros[0]);
                                    ^
Main.java:9: error: array required, but String found
    int b = Integer.parseInt(numeros[1]); 
                                    ^
3 errors

                    
#5
Error de compilación
                      Main.java:7: error: incompatible types: String[] cannot be converted to String
    String numeros = input.split("\\s+");
                                ^
Main.java:8: error: array required, but String found
    int a = Integer.parseInt(numeros[0]);
                                    ^
Main.java:9: error: array required, but String found
    int b = Integer.parseInt(numeros[1]); 
                                    ^
3 errors

                    
Puntos totales: 0 / 100

Código

import java.util.Scanner;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String input = sc.next();
    sc.close();
    String numeros = input.split("\\s+");
    int a = Integer.parseInt(numeros[0]);
    int b = Integer.parseInt(numeros[1]); 
    

    System.out.printf("%d\n",a+b);
  }

}