あと千回のお兄ちゃん
第 n 回萌理賞非応募作品
#include<stdio.h> int func(int x) { return 193.5+x*(-11.5+x*(-52.54+x*(14.252+x*(27.6366+x*(-2.96785 +x*(-4.349277+x*(0.2042741+x*(0.25519180+x*(-0.004338900 +x*-0.0048928020))))))))); } void call() { int n; for(n=-5; n<=5; n++){ putchar(func(n)); } return; } int main(){ int i; for(i=0;i<1000;i++){ call(); } return 0; }
EUC-JP で「お兄ちゃん」と 1000 回表示します。
関数 func と call を以下のように変えると UTF-8 版になります。
int func(int x) { return 129.5+x*(-78.7+x*(98.62+x*(54.510+x*(-39.0466+x*(-9.32159 +x*(5.827960+x*(0.5583636+x*(-0.41715000+x*(-0.006656696 +x*(0.0152906379+x*(-4.9134130E-4+x*(-2.74671316E-4 +x*(1.70912121E-5+x*(1.90304258E-6+x*-1.55267248E-7)))))))))))))); } void call() { int n; for(n=-7; n<=8; n++){ putchar(func(n)); } return; }
実は JavaScript で作ろうとして挫折しました。
追記:JavaScript 版できた。
function func(x){ return Math.round(12362+x*(39727.75+x*(-49011.875+x*(64118.875/3.0+x*(-3895.625+x*746.375/3.0))))); } function call(){ for(var n=0; n<6; n++){ document.write(String.fromCharCode(func(n))); } } for(var i=0;i<1000; i++){ call(); }