打印数字521,笔画由汉字组成

/**
 * 打印数字521,笔画由汉字组成。
 * @author tiger
 * @date 2010-5-21
 */
public class wueryi {

 private int[][] array = 
 {
   {1,1,1,0,2,2,2,0,0,3},
   {1,0,0,0,0,0,2,0,0,3},
   {1,1,1,0,2,2,2,0,0,3},
   {0,0,1,0,2,0,0,0,0,3},
   {1,1,1,0,2,2,2,0,0,3},
 };
 
 private void print(String str)
 {
  if(str.length()!=3)
  {
   System.out.println("参数不正确。");
   return;
  }
  for (int i = 0; i < array.length; i++) {
   String str1 = "";
   for (int j = 0; j < array[i].length; j++) {
    int index = array[i][j];
    if(index == 0) // 空格占空间小于汉字
    {
     str1 += "     " ;
    }else{
     str1 += str.charAt(index - 1);
    }
   }
   System.out.println(str1);
  }
 }
 
 public static void main(String[] args) {
  new wueryi().print("云龙湖");
 }
}

 
原文地址:https://www.cnblogs.com/chaohi/p/2330340.html