C,27297/245 = 111.4
源代码(245字节)
#include<stdio.h>
main(int c,char**v){char*s;FILE*f=fopen("/tmp/x.c","w");fprintf(f,"#include<stdio.h>\n#include<stdlib.h>\nmain(){int a=%s,b=%s;printf(\"%s * %s = %%d\\n\",a*b);}",v[1],v[2],v[1],v[2]);fclose(f);system("cc -E /tmp/x.c >add.c");}
编译并在命令行上使用两个整数参数运行时,这将生成另一个C文件,其中包含计算其乘积所需的代码,并使用该-E
标志对其进行编译。此标志指定编译器应该预处理阶段和输出经处理的源代码(其中将包括的全部内容后停止stdio.h
和stdlib.h
)。
输出文件(27297字节)
# 1 "/tmp/x.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/tmp/x.c"
# 1 "/usr/include/stdio.h" 1 3 4
# 64 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/_types.h" 1 3 4
# 27 "/usr/include/_types.h" 3 4
# 1 "/usr/include/sys/_types.h" 1 3 4
# 32 "/usr/include/sys/_types.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 33 "/usr/include/sys/_types.h" 2 3 4
********* LINES 13-1273 OMITTED *********
long long
strtoq(const char *, char **, int);
unsigned long long
strtouq(const char *, char **, int);
extern char *suboptarg;
void *valloc(size_t);
# 3 "/tmp/x.c" 2
main(){int a=6,b=7;printf("6 * 7 = %d\n",a*b);}
运行输出代码的结果
输出文件另存为add.c
,可以编译并正常运行:
$ ./a.out 6 7
$ cc add.c -o add
$ ./add
6 * 7 = 42
$