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

Envío 4436

Problema 0x78 - Suma de 2 números

  • Autor: sergio95it
  • Fecha: 2021-06-20 23:35:17 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 nums = input.split("\\s+");
                             ^
Main.java:9: error: array required, but String found
    int a = Integer.parseInt(nums[0]);
                                 ^
Main.java:10: error: array required, but String found
    int b = Integer.parseInt(nums[1]);
                                 ^
3 errors

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

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

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

                    
#5
Error de compilación
                      Main.java:7: error: incompatible types: String[] cannot be converted to String
    String nums = input.split("\\s+");
                             ^
Main.java:9: error: array required, but String found
    int a = Integer.parseInt(nums[0]);
                                 ^
Main.java:10: error: array required, but String found
    int b = Integer.parseInt(nums[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();
    String nums = input.split("\\s+");
    
    int a = Integer.parseInt(nums[0]);
    int b = Integer.parseInt(nums[1]);

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