Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/09/2011, 18:38
mariomon17
 
Fecha de Ingreso: noviembre-2009
Mensajes: 846
Antigüedad: 14 años, 5 meses
Puntos: 34
Funcionamiento concursos de programacion.

Hola a todos, tengo varias dudas sobre los concursos de programacion.
Por ejemplo, hace poco Tuenti organizo uno y no se como funciona.

La informacion que ellos te dan es esta:
Cita:
Challenge 1: Super hard sum

Your amazing program should calculate the sum if the numbers given in each line, and output on line for each question with the response. Numbers can be negative, really big and lines contain extra spaces, so make your program resistant to input.

Your program will need to read from standard input, line by line till the end of the input. Consider each line a different question. For each line you read, output the sum of all the given numbers.

Sample input
2 3
4 5 -1

Sample output
5
8
Que es eso de input/output?

En la pagina http://www.ricardclau.com/2011/06/tu...oblemas-1-a-4/ publicaron la solucion que ellos dieron (en php).

Esta es la solucion:
Código PHP:
Ver original
  1. #!/usr/bin/php
  2. <?php
  3. $lines = ;
  4. foreach($lines as $line) {
  5.     echo array_reduce(preg_split('/\s/', trim($line)), 'bcadd') .  PHP_EOL;
  6. }
  7. ?>

No entiendo lo de file('php://stdin'),supongo que es la entrada o como funciona esto?

Un saludo y gracias por la informacion.