IamFromMars's blog

By IamFromMars, history, 7 years ago, In English

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 :)

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it +8 Vote: I do not like it

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 years ago, # ^ |
      Vote: I like it +13 Vote: I do not like it

    ( Output File: standard output )

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

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

      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 years ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        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 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

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

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

    Thanks it is working for me :)