Skip to content

Instantly share code, notes, and snippets.

@al42and
Last active February 10, 2017 22:16
Show Gist options
  • Save al42and/dfce3c134fe9f0cc61306fb137e7c2aa to your computer and use it in GitHub Desktop.
Save al42and/dfce3c134fe9f0cc61306fb137e7c2aa to your computer and use it in GitHub Desktop.
The (Not So) Ultimate Guide Of Reading Till EOF

Как читать до конца файла / EOF

C++

while (! std::cin.eof ()) {
  std::cin >> q >> v >> rho;
}

C

while(scanf("%lf %lf %lf", &q, &v, &rho) != EOF) {
  // ...
} 

Python

for line in sys.stdin:
  q, v, rho = map(float, line.split())

Java

Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
  q = sc.nextDouble();
  v = sc.nextDouble();
  rho = sc.nextDouble();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment