当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3428:Formatting function

题目描述

Text formatting functions (Format, sprintf, etc) are very common between programming languages. Your task is to implement a simplified one.

Formatting function receives format string and several arguments. Argument values are processed one by one and inserted into format string at positions designated by format specifiers. The following format specifiers must be implemented:

* %s — argument as a string
* %d — argument as an integer value, without any leading zeroes
* %% — literal '%' character

Formatting error is generated if:

* number of arguments required by format specifiers is not equal to the number of actually supplied arguments,
* argument for %d specifier contains non-digit character.
* '%' character in format string is not followed by either '%', 's' or 'd'.

输入解释

Input file contains format string followed by arguments, one per line.

Constraints

Number of arguments is not greater than 1000, length of each line is not greater than 50000 characters.

输出解释

Output file must contain a single string — either formatted text or ERROR in case of any formatting error.

输入样例
Sample Input 1
%d x %d %s %d
2
02
=
4
Sample Input 2
%s
Sample Input 3
%d
2a
输出样例
Sample Output 1
2 x 2 = 4
Sample Output 2
ERROR
Sample Output 3
ERROR
提示

Bold texts appearing in the sample sections are informative and do not form part of the actual data.


该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3428

最后修改于 2020-10-29T07:01:23+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 65536