– (x/(R*2)-1.2)^2 * (y/R-1)^3 + [ (x/(2*R)-1.2)^2 + (y/R-1)^-1 ]^3
R是大致半径, 这里是13..
这破烂代码有人要么, 在自习室学用VIM写的, 好恶心啊.. 还是没Emacs舒服
纯用iPad完成, 关于如果用iPad GCC, 点我的这篇文章
2011 3月9日Update: 竟然让我发现一个BUG.. 我说怎么图形右边有点毛糙, 25行的 p++ 要改成 ++q.. = =
#include <stdio.h> #include <string.h> float sqr(float a) { return a*a; } float tri(float a) { return a*a*a; } int main() { char poem[100]; strcpy(poem,"RosesAreRedVioletsAreBlueSugarIsSweetAndSoAreYou"); const int R=13; const int SCREENWIDTH=60; int p=0; for(int y=(R+5)*2;y>=0;y--) { for(int x=1;x<SCREENWIDTH;x++) { if( -( sqr((float)x/(R*2) - 1.2))*tri( (float)y/R-1 ) + tri( sqr ((float)x/(R*2)-1.2) + sqr((float)y/R-1) -1)<=0 ) { printf("%c",poem[p]); p=p++%strlen(poem); } else printf(" "); } printf("\n"); } return 0; }