Usually in school are used C,c++,java to brush OJ problem, the topic of AC in different languages to AC again, basically equivalent to translation. See the school's OJ support to submit PHP code, and then try a bit.
First, you'll have to use PHP, but if you're reading this blog to prove that you've done it, then test and submit.
When it comes to testing, after we've written a piece of code, we're definitely not going to commit it immediately, we have to test the program correctly, but we don't know how to test it.
Because can not be like C, C++,java, click on the compile run can immediately test.
In fact, when we were learning Java, the first thing we used was not the IDE, but a notepad, and then, in the DOS interface, into the code folder, with Javac Filename.java to compile Java code, generate Filename.class files, and then Java FileName to run the program.
PHP can also be used to run PHP programs in a similar way.
Java, or PHP, to the DOS interface to operate, you have to add the path first.
First, find the location of Php.exe, such as my is installed in the F:\wamp\bin\php folder, if not found, you can again my computer inside the upper right corner of the search Php.exe. And then copy his path, like mine is F:\wamp\bin\php. Then open My Computer--system Properties--Advanced system settings-environment variables. Find the path, and then the end of path, add a semicolon, remember the semicolon in the English state. Then paste the path you just copied, such as I added altogether; F:\wamp\bin\php, click OK. Determine whether the path is correct, only need to first use the cmd command to enter the DOS interface, and then the interface directly into PHP, if there is no prompt error, it proves successful.
The second step. is to start testing, PHP provides a standard output stream. The function prototype is
Mixed fscanf (Resource $handle, String $format [, mixed &$ ...]
The use of the function is specific reference http://php.net/manual/en/function.fscanf.php
Typically, the format used on OJ is
FSCANF (STDIN, "%d", $a)
The output can be in print or echo. However, be careful to use "\ n" for line breaks.
When the code is finished, in the DOS interface, enter the file where the code file, at this time not must be in the WWW folder (if so, everyone will be helpless to die), can be another folder. Then enter PHP filename.php, if there is an error, you will be prompted, if no response, it proves that the compilation passed, then you can enter the test data.
Comprehensive. End with one of the simplest a+b.
The code is as follows:
<?php while (fscanf (STDIN, "%d%d", $a, $b) = = 2) {
==2 is to determine whether the input is two numbers. print ($a + $b). "\ n"; }
As for some of the questions, the input is more complex, everyone's own slowly try!!!!
Brush OJ with PHP language