Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

Автор IamFromMars, история, 7 лет назад, По-английски

I am doing a gym contest and I the problem says ( Input File: A.in ) & ( Output File: standard output ) and whenever I submit I got WA what I must do.

Thanks In Advance :)

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

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

Good day to you,

well you have to read the problem from file "A.in" and output is same as you are used to it.

Every language have different way how to do it, in C++, one can write following lines at the very beginning of your programm:

freopen("A.in","r",stdin);

In case you will meet similar thing with output, you can use similar piece of code.

freopen("A.out","w",stdout);

These lines "transfer" stdin/stdout from standard input to "A.in". (So they must be used before the first usage of scanf)

Anyway note that those lines will obviously help you only in case your WA's were caused by the input ^_^

Good Luck & Have Nice Day!

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится +13 Проголосовать: не нравится

    ( Output File: standard output )

    So I think freopen("A.out","w",stdout); should not be needed.

    • »
      »
      »
      7 лет назад, # ^ |
        Проголосовать: нравится +13 Проголосовать: не нравится

      I totally agree, that is why there is following sentence above ^_^ : "In case you will meet similar thing with output, you can use similar piece of code."

      And good day to you too! ^_^

      • »
        »
        »
        »
        7 лет назад, # ^ |
        Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

        I am trying to solve a problem which asks to change th input put used this way and i got WA in this Code what is the wrong

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

          you should remove freopen("I.in","r",stdin); as they did not ask you to read from I.in

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится +5 Проголосовать: не нравится

    Thanks it is working for me :)