Topic: 请问怎么样Applet里产生这样的图案。 |
Print this page |
1.请问怎么样Applet里产生这样的图案。 | Copy to clipboard |
Posted by: jack85017 Posted on: 2004-08-11 16:49 我是新手,不好意思,问了一个特简单的问题。还请大家原谅。 就是怎样输出下面这个: # ## ### #### ##### 我用for输入的是 # # # # # 我不知道用哪种方法能输出要求的图案。,准确的说我是不知道程序思想了。请大家告诉我程序思想就行。我研究不通了GGJJM再告诉我代码?谢谢了。 我的写的是 “public void paint(Graphics g) { int xpos=10,ypos=10; int a; for(a=1;a<6;a++){ for(b=1;b<2;b++) { g.drawString("#",xpos,ypos); xpos=xpos+10; } xpos=10; ypos=ypos+10;” |
2.Re:请问怎么样Applet里产生这样的图案。 [Re: jack85017] | Copy to clipboard |
Posted by: 519632 Posted on: 2004-08-11 17:12 for(b=1;b<=a;b++) |
3.Re:请问怎么样Applet里产生这样的图案。 [Re: jack85017] | Copy to clipboard |
Posted by: jack85017 Posted on: 2004-08-11 17:37 谢谢GG。我试试去。 |
4.Re:请问怎么样Applet里产生这样的图案。 [Re: jack85017] | Copy to clipboard |
Posted by: Jacky_one Posted on: 2004-08-11 18:25 下面的代码可以帮你搞定 class Daan { public static void main(String args[]) { char twoD[][] = new char[5][]; twoD[0] = new char[1]; twoD[1] = new char[2]; twoD[2] = new char[3]; twoD[3] = new char[4]; twoD[4] = new char[5]; int i, j, k = 0; for(i=0; i<5; i++) for(j=0; j<i+1; j++) { twoD[i][j] = '#'; k++; } for(i=0; i<5; i++) { for(j=0; j<i+1; j++) System.out.print(twoD[i][j] + " "); System.out.println(); } } } |
5.Re:请问怎么样Applet里产生这样的图案。 [Re: 519632] | Copy to clipboard |
Posted by: jack85017 Posted on: 2004-08-12 12:06 519632 wrote: OK试种方法试过了。不错。谢谢了。 |
6.Re:请问怎么样Applet里产生这样的图案。 [Re: Jacky_one] | Copy to clipboard |
Posted by: jack85017 Posted on: 2004-08-12 12:47 Jacky_one wrote: /**大哥写的有点复杂了。但是能运行出来。谢谢了。 |
7.Re:请问怎么样Applet里产生这样的图案。 [Re: jack85017] | Copy to clipboard |
Posted by: Jacky_one Posted on: 2004-08-12 17:40 程序多, 但是简单啊 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |