当前位置:网站首页>C语言编写“Hello World”挑战赛,你会如何作答?
C语言编写“Hello World”挑战赛,你会如何作答?
2022-07-22 23:28:00 【CSDN 程序人生】
近日,国外代码编写平台Intervee上创建了一个简单的编程挑战(挑战链接:https ://platform.intervee.io/get/play_/ch/hello_[w09]orld),要求解答者print "Hello World",但是代码不能使用字母W或者任何数字。
虽然该挑战面向的是初级开发人员,但是仍有很多2年以上工作经验的开发人员参与并公开了解决方案。(173位用户尝试解题,共有148位在没收到虚拟面试官提示的情况下,在推荐时间内挑战成功了。)

其中,只有30%的解答者是初级(0-2年经验)开发人员,同时85%未按时解决问题的解答者也是初级开发人员。这也意味着这项挑战对新手来说很难,听起来也是检查候选人是初级还是高级的好方法。
最后,平台挑选了几个有趣的结果分享了出来,下面一起来看看吧!
一、最常见和最简单的:使用 %c 说明符
提醒:ascii中的char 87是W
printf("Hello %corld", ++*(char[]){"V"});
printf("Hello %corld", *"V" | *"A");
printf("Hello %corld", *"*" + *"-");
char c = c^c++;
c=(c<<(c+c+c+c+c+c))+(c<<(c+c+c+c))+(c<<(c+c))+(c<<c)+c;
printf("Hello %corld",c);
printf("Hello %corld", EUSERS);这是最短的代码,EUSERS 确实是 87:
https://kernel.googlesource.com/pub/scm/linux/kernel/git/nico/archive/+/v0.97/include/linux/errno.h
二、酷酷的C++解决方案:
char c = (sizeof(bool)+sizeof(short)) * (sizeof(long) * sizeof(float) - sizeof(char) - sizeof(short));
cout << "Hello " << c << "orld";值得一提的是,解决方案被保存为多个步骤,因此可以看到解答者是如何进行的,而不仅仅是他的最终解决方案。比如说(来自: Interway.AI interactive challenges)

三、超酷的Python解决方案:
from googletrans import Translator
text = 'Hola Mundo!'
translator = Translator()
print(translator.translate(text).text)
import hello
# _hellol is a known library that prints hello world. Problem solved.四、C 和 C++ 中的“加密”方法:
char str[] = "Obkkh'Phukc\n";
char strPtr = str; while (strPtr != '\n') *strPtr++ ^= '\a';
printf("%s", str);五:同样的方法,在 C++ 中:
std::string str = "V_xyz";
char v_x;
for(auto i:str){ v_x=i; break; }
v_x++;
std::cout<<"Hello "<<v_x<<"orld";六:酷炫的作弊方案:
system("echo \"echo Hello World\" > /usr/bin/gcc");解答者发现挑战使用 /usr/bin/gcc处的gcc来编译代码,于是将其替换为“echo Hello World”,超级好!
最后,你还有其他独特的解决方案吗?欢迎参与挑战!
原文链接:10 ways to write Hello World in C - Interway.AI
《新程序员001-004》已全面上市,欢迎扫描下方二维码或点击进入立即订阅,即可畅享电子书及精美纸质书!

边栏推荐
- Typora set the title to automatically add sequence number
- flink通过ProcessFunction和定时器onTimer实现一个窗口累加的功能
- Shell variables, system predefined variables $home, $pwd, $shell, $user, custom variables, special variables $n, $, $*, [email protected],
- Dark horse programmer - interface testing - four-day learning interface testing - the second day - Interface use case design, test points, function testing, security testing, performance testing, sing
- 浅谈——网络安全架构设计(二)
- Chapter 3 stack
- 【超全整理】思科和华为命令对比备忘录,拿走不谢!随时随地可查看
- 小程序商城如何精细化运营会员?
- DP+回溯分割回文串的系列问题
- 什么是NFT?你不会还不知道吧!
猜你喜欢

算法---二维数组网格迁移(Kotlin)

阿里云国际版注册成功后添加支付方式

Keras深度学习实战(15)——从零开始实现YOLO目标检测

Layout drawing of semi customized digital inverter
[email protected], "/>Shell variables, system predefined variables $home, $pwd, $shell, $user, custom variables, special variables $n, $, $*, [email protected],

1.学会看懂网页

Bryntum Kanban task board 5.1.0 JS Kanban

Since I used the hiflow scene connector, I don't have to worry about becoming a "drowned chicken" anymore

【GNN报告】香港科技大学李佳:图异常检测再思考—我们究竟需要怎样的图神经网络?

Program environment and pretreatment
随机推荐
网站图标的实现
Jedis operation redis
Algorithm --- use the minimum cost to climb stairs (kotlin)
沉淀2年的 Jira 自动化经验分享
「疯狂食客」的元宇宙新布局「原始立方」,收藏价值几何?
Let's talk about the charm of code language
【WinSock】TCP UDP Boardcast Multicast
标准C语言10
【OPENVX】对象基本使用之vx_reference
什么是NFT?你不会还不知道吧!
工控人,你真的了解你的五险一金吗?
浅谈——网络安全架构设计(三)
Shell variables, system predefined variables $home, $pwd, $shell, $user, custom variables, special variables $n, $, $*, [email protected],
编写代码,多个字符从两端移动,向中间汇聚
Understand the interrupt system in STM32 in simple terms -- from principle to simple engineering examples -- nanny level tutorial
What if Alibaba cloud international forgets its member name or login password?
What level of futures company is founder metaphase? Is the account opening safe and reliable?
Add payment method after successful registration of Alibaba cloud international edition
Yaml syntax introduction and various data types
Intel raid模拟器下载