#K73272. HTML Tag Generator
HTML Tag Generator
HTML Tag Generator
You are given an HTML tag name and a list of attributes. Your task is to generate a valid HTML tag string by following these rules:
- Output the attributes sorted in alphabetical order by their keys.
- If an attribute value is the boolean
True
(represented as the string "True" in the input), then output only the attribute name without a value assignment. - For all other attributes, output them in the format
key="value"
. - If there are no attributes provided, the tag should be self-closing.
- When attributes exist, the tag should have an opening tag with attributes and a closing tag.
The output should exactly match the expected HTML string.
Note: All formulas or special expressions, if any, must be written in \( \LaTeX \) format.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains a string representing the HTML tag name.
- The second line contains an integer (N), the number of attributes.
- Each of the next (N) lines contains an attribute represented by a key and a value separated by a space.
If the value is exactly "True", treat it as a boolean attribute.
outputFormat
Print the generated HTML tag on a single line to standard output (stdout). The attributes in the tag must be sorted alphabetically by key. If no attributes are provided, output a self-closing tag.## sample
img
0
![]()