Hello Codeforcers,↵
↵
When I switched from Python to C++, I got a problem while inputting. I was stuck with it for 10 days until I realised how easy it is. I just want to write it here for others if they also get stuck here.↵
↵
In competitive programming, inputting more variables in one line is quite common.↵
↵
In Python, if you want to enter two variables in a single line, you have to do this:↵
↵
~~~~~↵
a, b = input().split()↵
~~~~~↵
↵
While in c++, **you can simply use 2 cins like your inputting in 2 lines. The way you do it (in line, spaced) doesn't matter.**↵
↵
~~~~~↵
string a, b;↵
cin >> a;↵
cin >> b;↵
~~~~~↵
↵
or↵
↵
~~~~~↵
string a, b;↵
cin >> a >> b;↵
~~~~~↵
↵
This way you can input a vector of size n in one line:↵
↵
~~~~~↵
vector<int> v(n);↵
↵
for(int i = 0; i < n; i++) {↵
cin >> v[i];↵
}↵
~~~~~↵
↵
↵
↵
↵
↵
↵
↵
When I switched from Python to C++, I got a problem while inputting. I was stuck with it for 10 days until I realised how easy it is. I just want to write it here for others if they also get stuck here.↵
↵
In competitive programming, inputting more variables in one line is quite common.↵
↵
In Python, if you want to enter two variables in a single line, you have to do this:↵
↵
~~~~~↵
a, b = input().split()↵
~~~~~↵
↵
While in c++, **you can simply use 2 cins like your inputting in 2 lines. The way you do it (in line, spaced) doesn't matter.**↵
↵
~~~~~↵
string a, b;↵
cin >> a;↵
cin >> b;↵
~~~~~↵
↵
or↵
↵
~~~~~↵
string a, b;↵
cin >> a >> b;↵
~~~~~↵
↵
This way you can input a vector of size n in one line:↵
↵
~~~~~↵
vector<int> v(n);↵
↵
for(int i = 0; i < n; i++) {↵
cin >> v[i];↵
}↵
~~~~~↵
↵
↵
↵
↵
↵
↵



