Markdown学习
标题
三级标题
四级标题
字体
Hello,world!
Hello,world!
Hello,world!
引用
分割线
图片
超链接
列表
A
B
C
A
B
C
表格
张三 | 男 | 1999.7.30 |
代码
public static void main(String[] args) {
//单心
heart(15,0.9,"love");
//双心
heartTwo(15,0.9,"爱","梁山伯","祝英台");
//点缀
heartTwoWithXK(15,0.9,"爱","梁山伯","祝英台");
}
private static void heart(int r,double size,String req){
size=1/(1.5*r*size);
StringBuilder sb=new StringBuilder();
for (int y = r; y > -r; y--,sb.append("\n"))
for (int x = -2*r; x < 2*r; x++ ) {
char msg=(req + req).charAt((x - y) % req.length() + req.length());
sb.append((inHeart(size,x,y)?msg+ " " : " "));
}
System.err.println(sb.toString());
}
private static void heartTwo(int r,double size,String center,String left,String right){
size=1/(1.5*r*size);
StringBuilder sb=new StringBuilder();
for (int y = r; y > -r; y--,sb.append("\n"))
for (int x = -2*r; x <4*r; x++ ) {
boolean isLeft=inHeart(size,x,y);
boolean isRight=inHeart(size,x-25,y-3);
//双空格
String req=null;
if(isLeft && isRight) req=center;
else if(isLeft) req=left;
else if (isRight) req=right;
if(req!=null) sb.append((req