Topic: 请教两个简单的算法,谢谢

  Print this page

1.请教两个简单的算法,谢谢 Copy to clipboard
Posted by: angui147
Posted on: 2005-11-11 21:31

1.如何打印下面的图形:

*********
*******
*****
***
*
用C,JAVA都可以

2.如何用JAVA实现一个双向链表,并实现插入,删除功能

谢谢!

2.Re:请教两个简单的算法,谢谢 [Re: angui147] Copy to clipboard
Posted by: JBeginer
Posted on: 2005-11-24 16:25

第一个程序:n 可以随便写,由于在中午休息时写的,所以很乱,自己可以整理一下
public class Star
{
public static void main(String[] args)
{
int n=10;
int j=1;
while(j<10)
{
for(int i=0;i<n-j;i++)
System.out.print("*");
for(int i=0;i<j;i++)
System.out.print("");
System.out.println("");
j++;
}
}
}

3.Re:请教两个简单的算法,谢谢 [Re: angui147] Copy to clipboard
Posted by: kulatasana
Posted on: 2005-11-28 15:44

双向链表只要有parent和child两个方向就可以了.
添加删除只需要修改相关的节点的parent和child指向.

4.Re:请教两个简单的算法,谢谢 [Re: angui147] Copy to clipboard
Posted by: acl2005
Posted on: 2005-11-29 11:27

/:testDor.java
public class testDor{
public static void main(String[] args){
int i,j,n=10;
for(i=0;i<n;i++)
{
++i;
for(j=0;j<n-i;j++)
System.out.print("*");
System.out.println();
}

}
}

5.Re:请教两个简单的算法,谢谢 [Re: angui147] Copy to clipboard
Posted by: addmin
Posted on: 2005-11-29 11:49

我是新手,请多指教。


   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