(Ответ TLDR: включите оператор: cin.sync_with_stdio(false) или просто используйте вместо него fgets.
Результаты TLDR: прокрутите мой вопрос до конца и посмотрите на таблицу.)
Код C++ :
Код: Выделить всё
#include
#include
using namespace std;
int main() {
string input_line;
long line_count = 0;
time_t start = time(NULL);
int sec;
int lps;
while (cin) {
getline(cin, input_line);
if (!cin.eof())
line_count++;
};
sec = (int) time(NULL) - start;
cerr
Подробнее здесь: [url]https://stackoverflow.com/questions/9371238/why-is-reading-lines-from-stdin-much-slower-in-c-than-python[/url]