坚定的真正程序员可以用任何语言编写Fortran程序。
从真正的程序员不要使用Pascal
您的任务是用所选择的编程语言编写程序,但只允许使用另一种语言。也就是说,抛弃一种语言中的所有编码约定,代之以另一种语言的编码约定。越多越好。使您的程序看起来像是用另一种语言编写的。
例如,讨厌Java的Python粉丝可以用Java编写以下Python程序:
void my_function() {
int i = 9 ;
while(i>0) {
System.out.println("Hello!") ;
i = i - 1 ;}}被迫使用C语言的Pascal爱好者可以这样写:
#define begin {
#define end }
#define then
#define writeln(str) puts(str)
if (i == 10) then
begin
writeln("I hate C");
end你必须写完整的程序。这个程序不需要做任何有用的事情。
祝好运。这是一场受欢迎的比赛,所以得票最多的代码赢了!
发布于 2014-03-21 10:28:22
中的应用
#include <stdio.h>
int main(int argc, char** argv)
{
printf("Hello world!\n");
return 0;
}发布于 2014-03-25 10:02:18
#include <stdio.h>
#define This
#define program int main() {
#define aims
#define to
#define output printf(
#define some
#define example
#define text(a) #a
#define the
#define screen "\n");
#define it
#define also
#define will
#define calculate ;int a =
#define result
#define of
#define and
#define print ; printf("%d\n", a);
#define seriously return 0; }
This program aims to output some example text (Hello) to the screen;
it also will calculate the result of 3 + 4 and print the result; seriously有什么办法消除;吗?
发布于 2014-03-21 05:29:35
我想聪明的伦纳特·奥古斯松已经赢了两次了。
首先,下面是他从2009年开始实现BASIC作为Haskell Monadic DSL的“周末黑客”的一个例子:
import BASIC
main = runBASIC' $ do
10 LET I =: 1
20 LET S =: 0
30 LET S =: S + 1/I
40 LET I =: I + 1
50 IF I <> 100000000 THEN 30
60 PRINT "Almost infinity is"
70 PRINT S
80 END它通过重载数字类型来工作。行号实际上是接受参数的函数。行的其余部分是函数的参数。该函数返回抽象语法树的表示形式,供基本解释器使用。
我还建议你看看奥古斯松参加2006年国际混淆C大赛的参赛作品,在比赛中他设法挤进了4k:
他们可以共享同一个文件,因为字节码放在C注释中。
自从我跟踪奥古斯松的作品已经有几年了,所以从那以后,他可能还想出了其他的绝妙的事情.
https://codegolf.stackexchange.com/questions/24623
复制相似问题