在一行中创建前缀序列
给定初始化变量 unsigned a
、unsigned b
且 b > a
和 std::vector
。如何用元素填充ba
的字符串字符串
,例如“x3”“x4”“x5”“x6”
(如果a=3
和< code>b=7) 对于任意 a
和 b
使用一个 C++ 命令(意味着一个分号:))?
Given the initialized variables unsigned a
, unsigned b
with b > a
and std::vector<std::string> strings
of size b-a
. How can I fill strings
with the elements e.g. "x3" "x4" "x5" "x6"
(in case a=3
and b=7
) for arbitrary a
and b
with one C++ command (meaning one semicolon at all :))?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这是多么大的挑战啊!
另外,将冗长的内容与曼努埃尔的答案进行比较:)
What a challenge!
Also, compare verbosity with Manuel's answer :)
#define IM_NOT_A_SEMICOLON_REALLY ;
然后随意继续。#define IM_NOT_A_SEMICOLON_REALLY ;
then proceed at will.不太有挑战性...
Not too challenging...
UncleBen 答案的衍生版本,但仅使用 STL
a derivate of UncleBen's answer but using only the STL
滥用逗号运算符,这显然不是分号:
Abusing comma operators, which are obviously not semicolons: