Codeforces and Polygon may be unavailable from December 6, 19:00 (UTC) to December 6, 21:00 (UTC) due to technical maintenance. ×

Hepic_Antony_Skarlatos's blog

By Hepic_Antony_Skarlatos, 10 years ago, In English

I saw,that codeforce support javascript and php. I am reading both of them,these days,I would love to solve some problems with them. The problem,is that I do not know how to read the input with these language.

Could you help me??? I really appreciate it. :D

»
10 years ago, # |
  Vote: I like it 0 Vote: I do not like it

In PHP try:

$s = file_get_contents('php://stdin');
// or sometimes also:
$s = file_get_contents('php://input');

In JavaScript, I believe:

var s = readline();

Probably most of Div2 A/B problems could be solved in scripting languages but you should not expect them quite usable.

  • »
    »
    10 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yea you are right in the last setence... I just want to use them here,just for learning the language...not to solve complex problems.

    For the code lines,I will check them. Thank you for your time !!!

    • »
      »
      »
      10 years ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      I just want to use them here,just for learning the language

      Then you may have a look at my small site — problems here are simpler and no restrictions on execution will bore you — since only answer is checked, ha-ha.

      Sorry for advertising :)

»
10 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

PHP: You may try:

$input = fgets(STDIN, 4);

Echo to output

JavaScript:

Is prompt / alert work ?

(I am using my phone right now to access Codeforces, so I am too lazy to test it)