Por ejemplo, hace poco Tuenti organizo uno y no se como funciona.
La informacion que ellos te dan es esta:
Cita:
Que es eso de input/output?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
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
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
#!/usr/bin/php <?php $lines = ; foreach($lines as $line) { } ?>
No entiendo lo de file('php://stdin'),supongo que es la entrada o como funciona esto?
Un saludo y gracias por la informacion.