SPyofgame's blog

By SPyofgame, history, 4 weeks 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

»
4 weeks ago, # |
  Vote: I like it -6 Vote: I do not like it

Look for varargs in C

»
4 weeks ago, # |
  Vote: I like it +10 Vote: I do not like it
For versions >= C++14
Or like this
  • »
    »
    4 weeks 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
  • »
    »
    4 weeks 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
  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    What happened ;-; ? I use vscode

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Run code in CUSTOM TEST doesnt work too

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

    Yes they are <3 Thanks

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

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

    • »
      »
      »
      4 weeks 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){
          ...
      }
      
      • »
        »
        »
        »
        4 weeks 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

      • »
        »
        »
        »
        4 weeks 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

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

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