程序员的日复一日的敲代码总是留下了枯燥与无味,为了挽留一段感情,给大家分享一断我的表白小代码.
public class Jingjing {
public static void main(String[] args)
{
System.out.println(printHeart("||"));
}
private static String printHeart(String input){
int[] array = {0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 4, 5, 2, 3, 4, 1, 0, 1,0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, , 0, 0};
StringBuffer pi = new StringBuffer();
for (int i = 0; i < array.length; i++) {
if(i % 7 == 0)
pi.append("\n");
if(array[i] == 0)
pi.append(" * ");
else if(array[i] == 5)
pi.append(" ");
else if(array[i] == 2)
pi.append("我想静");
else if(array[i] == 3)
pi.append("静 ");
else
pi.append(" "+input);
}
return pi.toString();
}
}
这是完成后的效果图.因为格式原因,会有一定的变动
|| ||
|| || || ||
|| || ||
|| * 我想静静 *||
|| ||
|| ||
|| |
|