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

建议使用的浏览器:

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

3997:Super macros

题目描述
SuperHacker is a advanced Hacker. He often write GNU style macros to optimize the programs. One day pooorman gave him a batch of ugly style c code using nested ternary operator (? :), which makes the code difficult to comprehend.

Now SuperHacker turn to you for help, he have write a program to collect all the ugly code into a file, he send such file to you. Please write a utility to convert such file into a GNU C marcos header file.
输入解释
Input contains multiple valid (nested) c ternary operator expression. Each will be ended with a semicolon. There will be no empty expressions.
输出解释
For each case, generate a GNU C style macro function named with SuperHacker_functionn, n is the case num, which is started from 0. There should be a blank line between each case. Each case should be output as the Sample Output below.

Each line of the output should be indented well with tab(\t) as Sample output. The trailing line continuing symbol backslashs(\) macro end symbol '})' at the last line of a macro should be right aligned with tabs aligned. Each continuing symbol and macro end symbol '})' should be seperated with the code in such line with at least one tab indent. The tab symbol considered 8 word width.

To make the macro file includable, you should add some code to prevent multiple including at the begin and end of the output file, Same as the sample output below.

You should trim the redundancy parenthesis.
输入样例
a? b: c;
((a)? b: c)?
 (d): e;
  (             		welcome_to_acm_icpc_online_judge		   )		;
输出样例
#ifndef MACROS_H
#define MACROS_H

#define SuperHacker_function0()	\
({	int _r;			\
	if (a)			\
		_r = b;		\
	else			\
		_r = c;		\
	_r;			})

#define SuperHacker_function1()	\
({	int _r;			\
	if (a)			\
	{			\
		if (b)		\
			_r = d;	\
		else		\
			_r = e;	\
	}			\
	else			\
	{			\
		if (c)		\
			_r = d;	\
		else		\
			_r = e;	\
	}			\
	_r;			})

#define SuperHacker_function2()			\
({	int _r;					\
	_r = welcome_to_acm_icpc_online_judge;	\
	_r;					})

#endif /* MACROS_H */
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3997

最后修改于 2020-10-25T23:09:08+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)