You are on page 1of 3

Entrada: dos nmeros reales (de teclado)

Salida: su suma (por pantalla)


Batera de pruebas: Caso 1: Entrada -5.2 7 Salida esperada: 1.8
Variables: x, y tipo punto flotante
Algoritmo:
Inicio
leer x, leer y
escribir x+y
Fin

Programa en Python:

x = float(raw_input())
y = float(raw_input())
print x+y

Programa en Pascal:

program suma (input, output) ;


var x, y : real;
BEGIN
readln (x); readln (y);
writeln (x+y);
END.

Programa en C:

#include <stdio.h>
main(){
double x, y;
scanf ("%lf", &x); scanf ("%lf", &y);
printf ("%lf\n", x+y);
}

Programa en Java:

import java.util.Locale;
import java.util.Scanner;
public class Suma {
public static void main(String[] args) {
double x, y;
Scanner teclado = new Scanner(System.in);
teclado.useLocale(Locale.US);
x = teclado.nextDouble(); y = teclado.nextDouble();
System.out.println (x+y);
}
}
Programa para el Java:

Compiled from "Suma.java"


public class Suma {
public Suma();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return

public static void main(java.lang.String[]);


Code:
0: new #2 // class java/util/Scanner
3: dup
4: getstatic #3 // Field java/lang/System.in:Ljava/io/InputStream;
7: invokespecial #4 // Method java/util/Scanner."<init>":(Ljava/io/InputStream;)V
10: astore 5
12: aload 5
14: getstatic #5 // Field java/util/Locale.US:Ljava/util/Locale;
17: invokevirtual #6
// Method java/util/Scanner.useLocale:(Ljava/util/Locale;)Ljava/util/Scanner;
20: pop
21: aload 5
23: invokevirtual #7 // Method java/util/Scanner.nextDouble:()D
26: dstore_1
27: aload 5
29: invokevirtual #7 // Method java/util/Scanner.nextDouble:()D
32: dstore_3
33: getstatic #8 // Field java/lang/System.out:Ljava/io/PrintStream;
36: dload_1
37: dload_3
38: dadd
39: invokevirtual #9 // Method java/io/PrintStream.println:(D)V
42: aload 5
44: invokevirtual #10 // Method java/util/Scanner.close:()V
47: return
}
Programa en ensamblador

.file "Suma.c" call __isoc99_scanf


.section .rodata movl $.LC0, %eax
.LC0: leal 24(%esp), %edx
.string "%lf" movl %edx, 4(%esp)
.LC1: movl %eax, (%esp)
.string "%lf\n" call __isoc99_scanf
.text fldl 16(%esp)
.globl main fldl 24(%esp)
.type main, @function faddp %st, %st(1)
main: movl $.LC1, %eax
.LFB0: fstpl 4(%esp)
.cfi_startproc movl %eax, (%esp)
pushl %ebp call printf
.cfi_def_cfa_offset 8 leave
.cfi_offset 5, -8 .cfi_restore 5
movl %esp, %ebp .cfi_def_cfa 4, 4
.cfi_def_cfa_register 5 ret
andl $-16, %esp .cfi_endproc
subl $32, %esp .LFE0:
movl $.LC0, %eax .size main, .-main
leal 16(%esp), %edx .ident "GCC: (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3"
movl %edx, 4(%esp) .section .note.GNU-stack,"",@progbits
movl %eax, (%esp)

Programa ejecutable:

00000000 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
00000010 02 00 03 00 01 00 00 00 80 83 04 08 34 00 00 00
00000020 40 11 00 00 00 00 00 00 34 00 20 00 09 00 28 00
00000030 1e 00 1b 00 06 00 00 00 34 00 00 00 34 80 04 08
00000040 34 80 04 08 20 01 00 00 20 01 00 00 05 00 00 00
00000050 04 00 00 00 03 00 00 00 54 01 00 00 54 81 04 08
00000060 54 81 04 08 13 00 00 00 13 00 00 00 04 00 00 00
00000070 01 00 00 00 01 00 00 00 00 00 00 00 00 80 04 08
00000080 00 80 04 08 64 06 00 00 64 06 00 00 05 00 00 00
00000090 00 10 00 00 01 00 00 00 14 0f 00 00 14 9f 04 08
000000a0 14 9f 04 08 04 01 00 00 0c 01 00 00 06 00 00 00
000000b0 00 10 00 00 02 00 00 00 28 0f 00 00 28 9f 04 08
000000c0 28 9f 04 08 c8 00 00 00 c8 00 00 00 06 00 00 00
000000d0 04 00 00 00 04 00 00 00 68 01 00 00 68 81 04 08
000000e0 68 81 04 08 44 00 00 00 44 00 00 00 04 00 00 00
000000f0 04 00 00 00 50 e5 74 64 6c 05 00 00 6c 85 04 08
00000100 6c 85 04 08 34 00 00 00 34 00 00 00 04 00 00 00
... ... ... ...

You might also like