当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。
frkstyc has always wanted POJ to have a multiligual user interface. He has considered several schemes to implement the functionalities. Unfortunately, he has been occupied during the recent months, which prevents him from working on the development of POJ. Still, he would like to share some of his ideas in the hope that someone could finish the work for him.
One challenge in implementing a multilingual user interface is the manipulation of text messages. As you can easily identify, POJ has been developed with English as the primary language in its user interface. Hundreds of text messages that appear in web pages scatter in tens of source files as string resources. Isolating these string resources in the source files to faciliate the use of a unified programming interface for multilingualism support is itself a tedious and time-comsuming job and frequently triggers dismay in frkstyc. Besides, there are still some subtleties concerning differences between languages.
One particular such tricky aspect in which frkstyc is interested is word order. Consider the caption of the table in the page of Login Log. In English, it shall read “Last num login attempts by user”, where user appears after num. In Chinese, in contrast, it shall read “user的最后num次登录尝试”, where user appears before num. Such difference causes complexity. You may argue that the caption in English can be changed to “user’s last num login attempts” to avoid the trouble with Chinese. However, in the case of Spanish, it may not be that easy to reorder the words in “Los últimos num intentos de user por acceder” as in English.
frkstyc’s proposed solution is rather simplistic. He uses format strings with numbered placeholders. Take the aforementioned text messages for example. frkstyc creates the following three format strings
where {1} and {2} are the numbered placeholders. By supplying a format string and the array of arguments [num, user] to a formatting function which replaces {1} with num and {2} with user, frkstyc always gets desired result regardless of the choice of language. Furthermore, the backslash is designated as the escape character. An unescaped backslash escapes the immediately following character, which shall be directly copied to the output and not further processed. A placeholder is recognized if none of its comprised characters is escaped and the number immediately surrounded by braces is a valid 1-based index into the array of arguments. A recognized placeholder shall be replaced in the output by array element indexed by the number in braces.
frkstyc recognizes writing the formatting function as the only fun part in implementing the envisioned multilingualism support. He delightfully invites you to share such joy by also writing the function.
The input consists of a single test case. The test case contains at most 1001 lines, each being a string of at most 80 printable ASCII characters. The first string is the format string. The rest comprises the array of arguments.
Last {1} login attempts by {2} 20 frkstyc
Last 20 login attempts by frkstyc
时间上限 | 内存上限 |
1000 | 65536 |