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");}
コマンドラインで2つの整数引数を使用してコンパイルおよび実行すると、製品の計算に必要なコードを含む別の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
$