前几天写了个莫名其妙的主函数递归,
但是gist.GitHub.com被墙,
我就直接灵机一动, new了个仓库叫weird-code
专门放一些奇怪的,很沙雕的(非标准的)代码,link:
https://github.com/AMIRIOX/weird-code
但由于本人才疏学浅(就是太菜了),只想出两个奇怪代码(有一个还是个梗),所以希望有大佬可以fork本仓库并提交pull request, 谢谢大佬
奇怪代码实例:
// Please do not run in strict mode
// % clang++ recursion.cpp -o rec.exe
// clang++ version: 10.0.0
#include <iostream>
int main(int argc, char** argv) {
std::cout << argc << " ";
main(argc+1,nullptr);
}
还有一个彩蛋就是快捷编译的:cmpl.sh
# If the tests folder does not exist, create it.
if [ ! -d "../tests" ]; then
mkdir ../tests
fi
# Intercept file name without suffix
filename=$(echo $1 | cut -d . -f1)
# echo $filename
# Check the compiler and compile
if command -v clang++ >/dev/null 2>&1; then
clang++ $1 -o ../tests/$filename.exe
else
echo -e 'no exists clang, check gcc...\n'
if command -v g++ >/dev/null 2>&1; then
g++ $1 -o ../tests/$filename.exe
else
echo 'no exists compiler'
exit
fi
fi
../tests/$filename.exe
违规自删, 希望大家能支持/kel