大家帮忙呢,编个程序,打印输出“I love you”,用图形符号“*”组合拼出?

zdyzdy1121 2008-03-19 09:19:02
大家帮忙呢,编个程序,打印输出“I love you”,用图形符号“*”组合拼出?大家出招啊,小弟刚学j2se
...全文
2120 36 打赏 收藏 转发到动态 举报
写回复
用AI写文章
36 条回复
切换为时间正序
请发表友善的回复…
发表回复
@蜗牛先生 2008-03-20
  • 打赏
  • 举报
回复 1
这么多好心人那
zdyzdy1121 2008-03-20
  • 打赏
  • 举报
回复 1
16 点阵字母字模,长见识了,不错,谢谢火龙果,字摸软件你用的哪个啊,给出个最完美的程序呢,谢谢啦
xukejun_BabyY 2008-03-20
  • 打赏
  • 举报
回复
学习啦!
zapdos 2008-03-20
  • 打赏
  • 举报
回复
[Quote=引用 33 楼 bao110908 的回复:]
引用 29 楼 healer_kx 的回复:
火龙果哥哥,教你一招,要想哄人,吧那些都加密存储了,存成Base64的,然后再Zip成二进制字符串。
非常短小,别人都看不出来是怎么回事。


我没想要哄人啊,我只是想输出一些字母而已。
[/Quote]
用来哄女仔,代码当然是越长越好
女仔看到长的就喜欢
liang3212909 2008-03-20
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 bao110908 的回复:]
Java code # # #
# # # ##########
# # # # # #
# # # # # #
# # # ############## #########
# # ## # # # # #…
[/Quote]
  • 打赏
  • 举报
回复
[Quote=引用 29 楼 healer_kx 的回复:]
火龙果哥哥,教你一招,要想哄人,吧那些都加密存储了,存成Base64的,然后再Zip成二进制字符串。
非常短小,别人都看不出来是怎么回事。
[/Quote]

我没想要哄人啊,我只是想输出一些字母而已。
  • 打赏
  • 举报
回复
呵呵,还有楼上的方法好,读取系统字库,我一直对 AWT 的东西不熟。
haoxiongok 2008-03-20
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 bao110908 的回复:]
利用 16 点阵字母字模做了一个:


Java codeimport java.util.ArrayList;
import java.util.List;

public class Test {

public static void main(String[] args) {
int[] LETTER_I = {0x0000,0x0000,0x0000,0x1FF8,0x01C0,0x01C0,0x01C0,0x01C0,
0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x1FFC,0x0000,0x0000};
int[] LETTER_l = {0x0000,0x0000,0x0080,0x0FC0,0x01C…
[/Quote]
zapdos 2008-03-20
  • 打赏
  • 举报
回复

*** *** *** *** *** ******* ** ** ********* *** *** *****
*** *** *** ** ** ******* *** ** ********* *** *** *******
*** *** *** *** *** *** **** ** *** *** *** *** **
*** *** *** *** *** ******* **** ** *** *** *** ****
*** *** *** ** ** ******* ** ** ** *** *** *** *****
*** *** *** ** ** *** ** **** *** *** *** ***
*** *** *** *** ***** *** ** **** *** *** *** ** ***
******* ****** *** ******* ** *** *** ****** *******
***** **** *** ******* ** ** *** **** *****

*** *** *** ***
*** *** *** ***
*** *** *** *** *** **** *** *** *** *** ***
*** *** ***** ** ** ** *** ***** ***** *** ***
*** *** *** *** ** ** *** *** *** *** *** *** ***
*** *** *** *** ** ** ******* *** *** *** *** ***
*** *** *** *** *** *** *** *** *** *** ***
*** ****** ***** *** ****** *** ***** *******
*** ****** *** *** **** *** *** ** ***

healer_kx 2008-03-20
  • 打赏
  • 举报
回复
火龙果哥哥,教你一招,要想哄人,吧那些都加密存储了,存成Base64的,然后再Zip成二进制字符串。
非常短小,别人都看不出来是怎么回事。
zapdos 2008-03-20
  • 打赏
  • 举报
回复
这个问题一直困扰各大泡妞同僚这么久
我也来解一下
可以用Graphics2D来拿像素

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.util.*;
import java.awt.image.*;

public class test{
public test(){
BufferedImage image = new BufferedImage(78,20,BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.setFont(new Font("宋体", Font.PLAIN, 16));
g.drawString("我是白痴",2,image.getHeight()-2);
int[] p = image.getRGB(0,0,image.getWidth(),image.getHeight(),new int[image.getWidth()*image.getHeight()],0,image.getWidth());
for(int i=0;i<image.getHeight();i++)
for(int j=0;j<image.getWidth();j++)
System.out.print(p[i*image.getWidth()+j]==-1?(i%2==0?"*":"*"):" "+(j==image.getWidth()-1?"\n":""));
}
public static void main(String args[]){
new test();
}
}



** * * *
*** * * ******** * *
* * * * * * ************
* * * ******** *********** * *
* * * * * * * * *
*************** ******** * * * * **** ****
* * * * * ** * * *
* * * *************** * * * * * *
*** * * * *********** ******* * *
*** ** * * * * * * * * *
** * * * ****** * * * * * * *
* * * * * * * * * * * *
* ** * * * * * * * * * * ****
* * * * ** *********** * * * *
* * ** * ******* * * * * * *
* * *
  • 打赏
  • 举报
回复
如果有文件格式的话,就可以把所有的汉字都给提取出来的。
  • 打赏
  • 举报
回复
是啊,最好能从字库中读取,但是 16 点阵字模 HZK16.dat 我不知道它的文件格式是怎样的,
下回来的字模提取软件也没有说明,我只能一个字母一个字母地提了。
  • 打赏
  • 举报
回复
字模啊,又不会变化的,写死就写死呗。
healer_kx 2008-03-20
  • 打赏
  • 举报
回复
这不就是写死了嘛。。。 。。。
  • 打赏
  • 举报
回复
这次改进了一下,直接传入字符串就可以了,输出时算法也改进了一下,不需要再用 clone 了。
  • 打赏
  • 举报
回复
接上一楼

        letterMapping.put('a', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x07E0,0x1E78,
0x381C,0x07FC,0x1E1C,0x301C,0x303D,0x1FCE,0x0000,0x0000});
letterMapping.put('b', new int[]{0x0000,0x0000,0x0800,0x7800,0x1800,0x1800,0x19F0,0x1FFC,
0x1C0C,0x180E,0x180E,0x180E,0x181C,0x1FF0,0x0000,0x0000});
letterMapping.put('c', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x0F38,
0x181C,0x3800,0x3800,0x3804,0x1C0C,0x0FF8,0x0000,0x0000});
letterMapping.put('d', new int[]{0x0000,0x0000,0x0000,0x003C,0x001C,0x001C,0x03DC,0x0E7C,
0x381C,0x381C,0x381C,0x381C,0x1C3C,0x0FCE,0x0000,0x0000});
letterMapping.put('e', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x0F78,
0x180C,0x3FFE,0x3FFC,0x3800,0x1C0C,0x07F0,0x0000,0x0000});
letterMapping.put('f', new int[]{0x0000,0x0000,0x0000,0x01FE,0x0307,0x0700,0x3FF8,0x3FF8,
0x0700,0x0700,0x0700,0x0700,0x0700,0x3FF0,0x0000,0x0000});
letterMapping.put('g', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03EE,0x0E7E,
0x1818,0x1818,0x0FF0,0x1980,0x1FFC,0x383E,0x300E,0x1FF8});
letterMapping.put('h', new int[]{0x0000,0x0000,0x0800,0x7800,0x1800,0x1800,0x19F0,0x1FF8,
0x181C,0x181C,0x181C,0x181C,0x181C,0x7E3F,0x0000,0x0000});
letterMapping.put('i', new int[]{0x0000,0x0000,0x0000,0x01C0,0x01C0,0x0000,0x0FC0,0x0FC0,
0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x1FF8,0x0000,0x0000});
letterMapping.put('j', new int[]{0x0000,0x0000,0x0000,0x0038,0x0038,0x0000,0x01F8,0x01F8,
0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x1830,0x1FE0});
letterMapping.put('k', new int[]{0x0000,0x0000,0x0800,0x3800,0x1800,0x1800,0x187C,0x187C,
0x18E0,0x1B80,0x1EE0,0x1870,0x1838,0x7E3F,0x0000,0x0000});
letterMapping.put('l', new int[]{0x0000,0x0000,0x0080,0x0FC0,0x01C0,0x01C0,0x01C0,0x01C0,
0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x1FFC,0x0000,0x0000});
letterMapping.put('m', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x771C,0x7FFE,
0x31C6,0x31C6,0x31C6,0x31C6,0x31C6,0xFBEF,0x0000,0x0000});
letterMapping.put('n', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x79F0,0x7FF8,
0x181C,0x181C,0x181C,0x181C,0x181C,0x7E3F,0x0000,0x0000});
letterMapping.put('o', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E0,0x0F78,
0x380C,0x300E,0x700E,0x380E,0x181C,0x0FF0,0x0000,0x0000});
letterMapping.put('p', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x79E0,0x7FFC,
0x180E,0x180E,0x180E,0x180E,0x1C1C,0x1FF8,0x1800,0x7E00});
letterMapping.put('q', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03C0,0x1E7C,
0x381C,0x381C,0x301C,0x381C,0x181C,0x0FFC,0x001C,0x003E});
letterMapping.put('r', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7E3C,0x7EFE,
0x0F04,0x0E00,0x0E00,0x0E00,0x0E00,0x7FE0,0x0000,0x0000});
letterMapping.put('s', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03E8,0x0E7C,
0x180C,0x0F80,0x03F8,0x101C,0x180C,0x1FF8,0x0000,0x0000});
letterMapping.put('t', new int[]{0x0000,0x0000,0x0000,0x0000,0x0100,0x0300,0x3FF8,0x3FF8,
0x0300,0x0300,0x0300,0x0304,0x030C,0x01F8,0x0000,0x0000});
letterMapping.put('u', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x783C,0x783C,
0x181C,0x181C,0x181C,0x181C,0x183C,0x0FDE,0x0000,0x0000});
letterMapping.put('v', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3E1E,0x3E1E,
0x0C18,0x0E30,0x0720,0x0360,0x03C0,0x0180,0x0000,0x0000});
letterMapping.put('w', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7BCF,0x7BCF,
0x39CC,0x39CC,0x1BE8,0x1E78,0x0E70,0x0C30,0x0000,0x0000});
letterMapping.put('x', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3E3C,0x3E3C,
0x0720,0x03C0,0x01C0,0x0670,0x0C38,0x7E7E,0x0000,0x0000});
letterMapping.put('y', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3E3E,0x3E3E,
0x0E18,0x0630,0x0360,0x03E0,0x01C0,0x0180,0x1900,0x3E00});
letterMapping.put('z', new int[]{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1FF8,0x3FF8,
0x3070,0x01C0,0x0380,0x0704,0x1C0C,0x3FFC,0x0000,0x0000});

letterMapping.put('0', new int[]{0x0000,0x0000,0x0000,0x07F0,0x1C18,0x381C,0x380E,0x380E,
0x780E,0x380E,0x380E,0x381C,0x1C18,0x07F0,0x0000,0x0000});
letterMapping.put('1', new int[]{0x0000,0x0000,0x0000,0x01C0,0x0FC0,0x01C0,0x01C0,0x01C0,
0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x0FFC,0x0000,0x0000});
letterMapping.put('2', new int[]{0x0000,0x0000,0x0000,0x0FF8,0x181C,0x381C,0x181C,0x0038,
0x0070,0x01C0,0x0700,0x0C06,0x3FFC,0x3FFC,0x0000,0x0000});
letterMapping.put('3', new int[]{0x0000,0x0000,0x0000,0x0FF0,0x3838,0x381C,0x0038,0x03F0,
0x03F0,0x001C,0x000E,0x381C,0x381C,0x0FF0,0x0000,0x0000});
letterMapping.put('4', new int[]{0x0000,0x0000,0x0000,0x0030,0x00F0,0x01F0,0x0370,0x0C70,
0x1870,0x3070,0x3FFE,0x0070,0x0070,0x03FE,0x0000,0x0000});
letterMapping.put('5', new int[]{0x0000,0x0000,0x0000,0x1FFC,0x1800,0x1800,0x18C0,0x1FF8,
0x181C,0x001E,0x100E,0x381C,0x3818,0x0FF0,0x0000,0x0000});
letterMapping.put('6', new int[]{0x0000,0x0000,0x0000,0x07F8,0x0C3C,0x1808,0x3800,0x3FF8,
0x7C1C,0x780E,0x380E,0x380E,0x1C1C,0x07F0,0x0000,0x0000});
letterMapping.put('7', new int[]{0x0000,0x0000,0x0000,0x1FFE,0x3C0C,0x3018,0x0030,0x0060,
0x00C0,0x01C0,0x0380,0x0380,0x0380,0x0380,0x0000,0x0000});
letterMapping.put('8', new int[]{0x0000,0x0000,0x0000,0x0FF8,0x380C,0x300E,0x3C0C,0x1FF8,
0x0FF0,0x383C,0x300E,0x700E,0x380C,0x0FF0,0x0000,0x0000});
letterMapping.put('9', new int[]{0x0000,0x0000,0x0000,0x0FF0,0x3818,0x300C,0x700E,0x300E,
0x383E,0x1FEE,0x001C,0x1818,0x3C30,0x1FE0,0x0000,0x0000});

letterMapping.put(' ', SPACE);
}
}
  • 打赏
  • 举报
回复
呵呵,应大家的要求,做了个 A to Z, a to Z, 1 to 9, SPACE 共 63 个字符的程序,

代码太长,分两次发。

import java.util.HashMap;
import java.util.Map;

public class LetterMatrix {

public static void main(String[] args) {
LetterMatrix matrix = new LetterMatrix();
matrix.printString("Hello World");
}

private static Map<Character, int[]> letterMapping = null;
public final static int MATRIX_ARRAY = 16;
private final static int[] SPACE = new int[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

static {
init();
}

public void printString(String str) {
if(!str.matches("[0-9A-Za-z ]*")) {
throw new IllegalArgumentException("ONLY accept A to Z, a to z, 0 to 9 and space");
}
char[] chars = str.toCharArray();
printCharArray(chars);
}

private void printCharArray(char[] chars) {
int allchars[][] = new int[chars.length][];
for(int i = 0; i < chars.length; i++) {
allchars[i] = letterMapping.get(chars[i]);
}

for(int i = 0; i < MATRIX_ARRAY; i++) {
for(int j = 0, k = chars.length; j < k; j++) {
int[] letter = allchars[j];
int len = letter == SPACE ? 8 : 16;
for(int m = 0; m < len; m++ ) {
System.out.print((letter[i] & (0x8000 >> m)) == 0 ? " " : "#");
}
}
System.out.println();
}
}

private static void init() {
letterMapping = new HashMap<Character, int[]>();
letterMapping.put('A', new int[]{0x0000,0x0000,0x0000,0x01C0,0x03C0,0x02E0,0x0660,0x0C70,
0x0C70,0x0FF8,0x1838,0x1018,0x301C,0xFC3F,0x0000,0x0000});
letterMapping.put('B', new int[]{0x0000,0x0000,0x0000,0x7FF8,0x181C,0x181E,0x181C,0x1FF8,
0x1FFC,0x180E,0x180E,0x180E,0x181E,0xFFF8,0x0000,0x0000});
letterMapping.put('C', new int[]{0x0000,0x0000,0x0000,0x07FE,0x1C06,0x3802,0x7000,0x7000,
0x7000,0x7000,0x7002,0x3802,0x1C0C,0x07F8,0x0000,0x0000});
letterMapping.put('D', new int[]{0x0000,0x0000,0x0000,0x7FF0,0x183C,0x180E,0x180E,0x180E,
0x180F,0x180E,0x180E,0x180C,0x1838,0x7FE0,0x0000,0x0000});
letterMapping.put('E', new int[]{0x0000,0x0000,0x0000,0x7FFC,0x1C0E,0x1C02,0x1C10,0x1FF0,
0x1FF0,0x1C10,0x1C00,0x1C02,0x1C06,0x7FFC,0x0000,0x0000});
letterMapping.put('F', new int[]{0x0000,0x0000,0x0000,0x7FFE,0x1C06,0x1C00,0x1C18,0x1C38,
0x1FF8,0x1C18,0x1C00,0x1C00,0x1C00,0x7F00,0x0000,0x0000});
letterMapping.put('G', new int[]{0x0000,0x0000,0x0000,0x07F8,0x1C1C,0x380C,0x7000,0x7000,
0x7000,0x703F,0x701C,0x381C,0x1C1C,0x0FFC,0x0000,0x0000});
letterMapping.put('H', new int[]{0x0000,0x0000,0x0000,0x7C3F,0x381C,0x381C,0x381C,0x381C,
0x3FFC,0x381C,0x381C,0x381C,0x381C,0xFE3F,0x0000,0x0000});
letterMapping.put('I', new int[]{0x0000,0x0000,0x0000,0x1FF8,0x01C0,0x01C0,0x01C0,0x01C0,
0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x1FFC,0x0000,0x0000});
letterMapping.put('J', new int[]{0x0000,0x0000,0x0000,0x07FE,0x0070,0x0070,0x0070,0x0070,
0x0070,0x0070,0x0070,0x0070,0x0070,0x3070,0x78E0,0x3F80});
letterMapping.put('K', new int[]{0x0000,0x0000,0x0000,0x7E3E,0x1830,0x1860,0x19C0,0x1B80,
0x1FC0,0x18E0,0x1870,0x1838,0x181C,0x7E3F,0x0000,0x0000});
letterMapping.put('L', new int[]{0x0000,0x0000,0x0000,0x7E00,0x1C00,0x1C00,0x1C00,0x1C00,
0x1C00,0x1C00,0x1C00,0x1C03,0x1C06,0x7FFE,0x0000,0x0000});
letterMapping.put('M', new int[]{0x0000,0x0000,0x0000,0x781F,0x381E,0x3C3E,0x3C3E,0x2C6E,
0x2E6E,0x26CE,0x27CE,0x238E,0x238E,0xFB3F,0x0000,0x0000});
letterMapping.put('N', new int[]{0x0000,0x0000,0x0000,0x781F,0x3C04,0x3E04,0x3704,0x3384,
0x31C4,0x30E4,0x3034,0x301C,0x300C,0xFC04,0x0000,0x0000});
letterMapping.put('O', new int[]{0x0000,0x0000,0x0000,0x0FF0,0x1C1C,0x380E,0x700E,0x7007,
0x7007,0x7007,0x300E,0x380E,0x1C1C,0x07F0,0x0000,0x0000});
letterMapping.put('P', new int[]{0x0000,0x0000,0x0000,0x7FF8,0x1C0E,0x1C0E,0x1C0E,0x1C1C,
0x1FF8,0x1C00,0x1C00,0x1C00,0x1C00,0x7F00,0x0000,0x0000});
letterMapping.put('Q', new int[]{0x0000,0x0000,0x0000,0x0FF0,0x1C1C,0x380E,0x700E,0x7007,
0x7007,0x700F,0x738E,0x39CE,0x1C7C,0x07F0,0x003E,0x000C});
letterMapping.put('R', new int[]{0x0000,0x0000,0x0000,0x3FF8,0x1C1C,0x1C0E,0x1C0C,0x1C78,
0x1FE0,0x1CE0,0x1C70,0x1C38,0x1C1C,0x7E0F,0x0000,0x0000});
letterMapping.put('S', new int[]{0x0000,0x0000,0x0000,0x0FFC,0x301C,0x3004,0x3800,0x1F80,
0x03F0,0x003C,0x200E,0x200E,0x380C,0x3FF8,0x0000,0x0000});
letterMapping.put('T', new int[]{0x0000,0x0000,0x0000,0x3FFE,0x61C6,0x41C2,0x01C0,0x01C0,
0x01C0,0x01C0,0x01C0,0x01C0,0x01C0,0x0FF0,0x0000,0x0000});
letterMapping.put('U', new int[]{0x0000,0x0000,0x0000,0x7C1E,0x3804,0x3804,0x3804,0x3804,
0x3804,0x3804,0x3804,0x3804,0x1C18,0x0FF0,0x0000,0x0000});
letterMapping.put('V', new int[]{0x0000,0x0000,0x0000,0x7C1E,0x180C,0x1C18,0x0C10,0x0E30,
0x0E20,0x0760,0x0740,0x03C0,0x0380,0x0180,0x0000,0x0000});
letterMapping.put('W', new int[]{0x0000,0x0000,0x0000,0x7BCF,0x31C6,0x31C4,0x39CC,0x3BEC,
0x1BF8,0x1F78,0x1E78,0x0E70,0x0C30,0x0C20,0x0000,0x0000});
letterMapping.put('X', new int[]{0x0000,0x0000,0x0000,0x3E3E,0x0C18,0x0E30,0x0760,0x03C0,
0x01C0,0x03E0,0x0670,0x0C38,0x081C,0x7C3F,0x0000,0x0000});
letterMapping.put('Y', new int[]{0x0000,0x0000,0x0000,0x7E3E,0x1C08,0x0C10,0x0E30,0x0760,
0x03C0,0x01C0,0x01C0,0x01C0,0x01C0,0x0FF0,0x0000,0x0000});
letterMapping.put('Z', new int[]{0x0000,0x0000,0x0000,0x1FFE,0x381C,0x2038,0x0070,0x00E0,
0x01C0,0x0380,0x0600,0x0C06,0x380C,0x7FFC,0x0000,0x0000});


未完,待续
  • 打赏
  • 举报
回复
呵呵,字模是用字模软件提取的
caven110 2008-03-19
  • 打赏
  • 举报
回复
真积极
加载更多回复(16)

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧