SPyofgame's blog

By SPyofgame, history, 5 years ago, In English

I dont know how to use Template for multiple input. Can you help me ?

Fast Input Code

Sorry for my bad English. Correct me if I am wrong.

Thanks for reading <3

  • Vote: I like it
  • -25
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it +10 Vote: I do not like it
For versions >= C++14
Or like this
  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Int the first template:

    My test code
    It shows in the terminal
    Input
    Output
  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Int the second template:

    My test code
    It shows in the terminal
    Input
    Output
  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    What happened ;-; ? I use vscode

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

    Run code in CUSTOM TEST doesnt work too

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

The bug is in your original read_int

Both of these work fine.

First template
Second template
  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yes they are <3 Thanks

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

    But how can I detect if there is no valid input ?

    • »
      »
      »
      5 years ago, # ^ |
      Rev. 2   Vote: I like it +1 Vote: I do not like it

      You're welcome!

      I don't know how to manipulate that function, I believe cin/cout with sync is enough.

      If you meant how to read until the input ends, it's done like this:

      string s;
      while(cin >> s){
          ...
      }
      
      • »
        »
        »
        »
        5 years ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        Yes I know about it, but I mean to the template of custom cin >> operator

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

        well... actually I have just meet a problem where cin_with_sync is not enough :) And this is the first problem I need to use FastInput, I was surprised

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

    How can I check if there is no more arguments in parametter ?