简体   繁体   English

编程练习规范

[英]Programming exercise specification

As part of a programming exercise I received the following: 作为编程练习的一部分,我收到了以下内容:

"Simulator will receive orders from stdin in a simplified ascii format specified later in this document..." “模拟器将以标准ascii格式从stdin接收定单,稍后在本文档中指定...”

"Input is received from stdin, and is in comma-separated ascii format. You may assume that the input will always be correctly formatted" “输入是从stdin接收的,采用逗号分隔的ascii格式。您可以假定输入将始终正确格式化”

Example: 例:

B,100322,5103,7500 B,100322,5103,7500

This is all about the input mechnism. 这全都与输入机制有关。 What i don't understand is the stdin them mention - is that the usual console input by the user, file input etc. ? 我不明白他们提到的标准输入-是用户通常的控制台输入,文件输入等。

Usual console, yes. 通常的控制台,是的。

In Java, the standard streams are referred to by System.in (for stdin ), System.out (for stdout ), and System.err (for stderr ). 在Java中,标准流由System.in (对于stdin ), System.out (对于stdout )和System.err (对于stderr )引用。

See http://en.wikipedia.org/wiki/Standard_streams for further details 有关更多详细信息,请参见http://en.wikipedia.org/wiki/Standard_streams

标准输入是控制台System.in (如果未使用System.setIn(InputStream)重新定义)。

I googled stdin and the first match was http://en.wikipedia.org/wiki/Standard_streams which states 我用Google搜索stdin ,第一个匹配项是http://en.wikipedia.org/wiki/Standard_streams ,其中指出

The three I/O connections are called standard input (stdin), standard output (stdout) and standard error (stderr) 这三个I / O连接称为标准输入(stdin),标准输出(stdout)和标准错误(stderr)

So I googled stdin java and the first match was http://introcs.cs.princeton.edu/java/stdlib/StdIn.java.html 因此,我用stdin java进行了搜索,第一个匹配项是http://introcs.cs.princeton.edu/java/stdlib/StdIn.java.html

Which has 其中有

// assume Unicode UTF-8 encoding
private static String charsetName = "UTF-8";

// assume language = English, country = US for consistency with System.out.
private static Locale usLocale = new Locale("en", "US");

// the scanner object
private static Scanner scanner = new Scanner(new BufferedInputStream(System.in), charsetName);

You can change the charsetName = "ASCII" 您可以更改charsetName =“ ASCII”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM