Блог пользователя Hepic_Antony_Skarlatos

Автор Hepic_Antony_Skarlatos, 10 лет назад, По-английски

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

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
10 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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 лет назад, # ^ |
        Проголосовать: нравится +8 Проголосовать: не нравится

      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 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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)