I can’t find how to take inputs in this question coz student query and instructor query are having different no of integers input.
Ques - https://hack.codingblocks.com/contests/c/471/501
Student query takes 1 integer and instructor query takes 2 integers then how to distinguish between them for taking input and processing them.
I tried using map and pair but was stuck in very starting of code for taking inputs differently.
Prateek sir and coding
simply take integer. and if its 2 take input of other value, else display the top.
Thanks, but I am curious to know what if there was 1,2,3 etc at the place of 2 then how we would have distinguished both the instructor query and student query input.
since number of types of queries is generally less a switch or if else would be enough.
Ohk What if the cost is also less or equal to the no of queries?
Why should that matter as first input is going to be the type of query(after the no of queries) and you’ll perform action corresponding to that query only. So, if there is no input corresponding to that query you won’t take any and the incoming next input will imply query only.
Ok Thanks , but Is it possible to take 2 input and then followed by single input from the user without knowing that when he will give 1 input or 2 input and then work on them ? Like first we take the N value from the user and then he will enter N lines which can be single input (1 integer) or can be (2 integers). and then we have to treat single and double integers value differently.
Sorry for bothering you again but, Actually you are not getting what I am trying to say is that if the input was like this.
5
12 18
28 20
20
21
13 13
Then in this case how we will know that when to take one input and when to take 2 inputs?
in that case one method can be you can read each input as a string and find number of inputs by number of spaces present and convert each to integer.
I was thinking the same