FAQs EXAMPLES

¿Tienes alguna duda sobre URI Online Judge? ¡Aquí puedes encontrar la respuesta!

  • 1001 en C

    #include <stdio.h>
     
    int main() { 
        int A, B, X;
    
        scanf("%d", &A);
        scanf("%d", &B);
    
        X=A+B;
    
        printf("X = %d\n", X);
    
        return 0;
    }
    
  • 1001 en C++

    #include <iostream>
    
    using namespace std;
    
    int main() {
       int A, B, X;
    
       cin >> A >> B;
       X = A + B;
       cout << "X = " << X << endl;
    
       return 0;
    }
  • 1001 en C#

    using System; 
     
    class URI {
     
        static void Main(string[] args) { 
            int A = Int32.Parse( System.Console.ReadLine().Trim());
            int B = Int32.Parse( System.Console.ReadLine().Trim());
     
            int X = A + B;
     
            Console.Write("X = {0}\n", X);
        }
         
    }
    
  • 1001 en Java

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    
    public class Main {
        
        public static void main(String[] args) throws IOException {
            
            InputStreamReader ir = new InputStreamReader(System.in);
            BufferedReader in = new BufferedReader(ir);
            
            int A, B, X;
            
            A = Integer.parseInt(in.readLine());
            B = Integer.parseInt(in.readLine());
            
            X = A + B;
            
            System.out.printf("X = %d\n", X);
            
        }
        
    }
    
  • 1001 en Python

    a = input()
    b = input()
    
    X = a + b
    
    print "X = %i" % X
    
  • 1001 en Ruby

    a = gets.to_i 
    b = gets.to_i
    
    X = a + b
    
    puts "X = #{X}"
    
  • 1001 en Scala

    object Main {
        def main(args: Array[String]) {
            val A = io.StdIn.readLine().toInt
            val B = io.StdIn.readLine().toInt
          
            println("X = " + (A + B))
        }
    }
    
  • 1001 en Go

    package main
     
    import (
        "fmt"
    )
     
    func main() {
        var a,b int
        var x int
     
        fmt.Scanf("%d", &a)
        fmt.Scanf("%d", &b)
        x = a + b
         
        fmt.Printf("X = %d\n", x)
    }
    
  • 1001 en Kotlin

    import java.util.*
    
    fun main(args: Array<String>) {
        val sc = Scanner(System.`in`);
        
        val a: String = sc.next();
        val b: String = sc.next();
        
        println("X = " + (a.toInt() + b.toInt()));
    }
    
  • 1001 en JavaScript

    var input = require('fs').readFileSync('/dev/stdin', 'utf8');
    var lines = input.split('\n');
        
    var a = parseInt(lines.shift());
    var b = parseInt(lines.shift());
       
    console.log('X = ' + (a+b));
    
  • 1001 en Lua

    X = tonumber(io.read(), 10)
    Y = tonumber(io.read(), 10)
    
    print('X = ' .. X + Y)
    
  • 1001 en Pascal

    var
        a : int64;
        b : int64;
        x : int64;
    
    begin
        read(a);
        read(b);
        x := a + b;
        writeln('X = ', x);
    end.
    
  • 1001 en Haskell

    main :: IO ()
    main = do
            a <- readLn :: IO Int
            b <- readLn :: IO Int
            putStrLn $ id ("X = " ++ show(a + b))
    
  • 1001 en OCaml

    Scanf.scanf "%i %i\n" (fun a b ->
            Printf.printf "X = %d\n" (a + b);
    )
    
  • 1001 en PHP

    <?php
    $a = trim(fgets(STDIN));
    $b = trim(fgets(STDIN));
    $soma = $a + $b;
    
    echo "X = " . $soma . "\n";
    ?>
    
  • 1001 en Rust

    use std::io;
    
    fn main() {
        let mut inputA = String::new();
        let mut inputB = String::new();
    
        io::stdin().read_line(&mut inputA);
        io::stdin().read_line(&mut inputB);
    
        let a: i32 = inputA.trim().parse().unwrap();
        let b: i32 = inputB.trim().parse().unwrap();
    
        println!("X = {}", a + b);
    }
    
  • 1001 en R

    # Read multiple lines from stdin (must use 'r')
    input <- file('stdin', 'r')
    
    a <- as.integer(readLines(input, n=1))
    b <- as.integer(readLines(input, n=1))
    
    soma = a + b
    
    # Write to stdout (must use '')
    write(paste("X =", soma), '')
    
  • 1001 en Clojure

    (defn parse-int [s]
       (Integer. (re-find  #"\d+" s )))
    
    (def a (read-string (read-line)))
    (def b (read-string (read-line)))
    (println "X =" (+ a b))
    
  • 1001 en Dart

    import 'dart:io';
    
    void main()
    {
        int a = int.parse(stdin.readLineSync());
        int b = int.parse(stdin.readLineSync());
    
        int soma = a + b;
    
        print("X = $soma");
    }