herrDeng網內搜尋

自訂搜尋

Ads

2011年11月10日 星期四

LinkedList Exercise

輸入字串陣列a[0],a[1],...a[4]

利用Java Class LinkedList 作初一鏈結串列:

[ a[0], a[1], a[2], a[4], a[4],a[3],a[2],a[0] ]

Hint:可利用方法addFirst, add, remove.....

48 則留言:

B9933042 提到...

import java.util.*;
public class B1 {
public static void main(String[] args) {
String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"};
LinkedList<String> list=new LinkedList<String>();
for(String x:arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[4], a[3], a[2], a[0]");
System.out.println(list);



}

}

B9933052 提到...

package V1;

import java.util.*;
public class B9933052A {

public static void main(String[] args) {
String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"};
LinkedList<String> list=new LinkedList<String>();
for(String x:arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[4], a[3], a[2], a[0]");
System.out.println(list);



}

}

B9933002 提到...

import java.util.*;
public class a1 {


public static void main(String[] args) {
String arr[]={"你", "我", "他","YA","HI"};
LinkedList< String > list= new LinkedList< String >();
for (String x :arr)
list.addFirst(x);

list.remove(3);

int x=list.indexOf("HI");
if (x!=-1)
list.add(x,"你,他,YA,HI");
System.out.println(list);



}

}

B9933054 提到...

package pack1;
import java.util.*;
public class a1{
public static void main(String[] args) {
String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"};
LinkedList<String> list=new LinkedList<String>();
for(String x:arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[4], a[3], a[2], a[0]");
System.out.println(list);
}
}

B9933041 提到...

package P1;
import java.util.*;
public class B1 {

public static void main(String[] args) {

String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"};
LinkedList<String> list= new LinkedList<String>();
for(String x:arr)
list.add(x);
list.remove(3);

int y=4;
list.add(y,"a[4], a[3], a[2], a[0]");
System.out.println(list);


}

}

b9933011 提到...

import java.util.*;
public class b1 {
public static void main(String[] args) {
String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"};
LinkedList<String> list=new LinkedList<String>();
for(String x:arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[4], a[3], a[2], a[0]");
System.out.println(list);



}

}

B9933003 提到...

package pack;
import java.util.*;
public class pack {
public static void main(String[] args) {

String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"};
LinkedList<String> list=new LinkedList<String>();
for(String x:arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[4], a[3], a[2], a[0]");
System.out.println(list);




}

}

b9933009 提到...

package V1; import java.util.*; public class 2156415A { public static void main(String[] args) { String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList<String> list=new LinkedList<String>(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list); } }

b9933018 提到...

package V1; import java.util.*; public class 2156415A { public static void main(String[] args) { String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList<String> list=new LinkedList<String>(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list); } }

b9933039 提到...

package V1; import java.util.*; public class 2156415A { public static void main(String[] args) { String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList<String> list=new LinkedList<String>(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list); } }

b9933033 提到...

package V1; import java.util.*; public class 2156415A { public static void main(String[] args) { String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList<String> list=new LinkedList<String>(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list); } }

b9933034 提到...

package V1; import java.util.*; public class 2156415A { public static void main(String[] args) { String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList<String> list=new LinkedList<String>(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list); } }

B9933012 提到...

package p1;
import java.util.*;
public class b1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

String arr[]={"a[0]", "a[1]", "a[2]","a[3]","a[4]"};
LinkedList< String > list= new LinkedList< String >();
for (String x :arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[4],a[3], a[2],a[0]");
System.out.println(list);


}

}

B9933050 提到...

package pack1;
import java.util.*;
public class A1 {


public static void main(String[] args) {
String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"};
LinkedList< String > list= new LinkedList< String >();
for (String x :arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[4], a[3], a[2], a[0]");
System.out.println(list);

}

}

B9933049 提到...

String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList<String> list=new LinkedList<String>(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list);

B9933055 提到...

String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList<String> list=new LinkedList<String>(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list);

B9933038 提到...

package p1;
import java.util.*;
public class B1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String arr[]={"a[0]", "a[1]", "a[2]", "a[3]", "a[4]"};
LinkedList<String> list=new LinkedList<String>();
for (String x :arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[4], a[3] ,a[2], a[0]");
System.out.println(list);

}

}

B9933045 提到...

package p1;
import java.util.*;
public class ex1
{
public static void main(String[] args)
{
String arr[]={"a[0]", "a[1]", "a[2]","a[3]","a[4]"};
LinkedList< String > list= new LinkedList< String >();
for (String x :arr)
list.add(x);

list.remove(3);

int y=4;
list.add(y,"a[4], a[3], a[2], a[0]");
System.out.println(list);
}
}

B9933019 提到...

package p1;
import java.util.*;
public class B1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String arr[]={"a[0]", "a[1]", "a[2]", "a[3]", "a[4]"};
LinkedList<String> list=new LinkedList<String>();
for (String x :arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[4], a[3] ,a[2], a[0]");
System.out.println(list);

}

}

B9933044 提到...

package p1;
import java.util.*;
public class ex1
{
public static void main(String[] args)
{
String arr[]={"a[0]", "a[1]", "a[2]","a[3]","a[4]"};
LinkedList< String > list= new LinkedList< String >();
for (String x :arr)
list.add(x);

list.remove(3);

int y=4;
list.add(y,"a[4], a[3], a[2], a[0]");
System.out.println(list);
}
}

B9933055 提到...

String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList<String> list=new LinkedList<String>(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list);

B9933035 提到...

String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList<String> list=new LinkedList<String>(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list);

B9933021 提到...

package p1;
import java.util.*;
public class B1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String arr[]={"a[0]", "a[1]", "a[2]", "a[3]", "a[4]"};
LinkedList<String> list=new LinkedList<String>();
for (String x :arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[4], a[3] ,a[2], a[0]");
System.out.println(list);

}

}

b9933007 提到...

String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList<String> list=new LinkedList<String>(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list);

B9933013 提到...

package p1;
import java.util.*;
public class B1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String arr[]={"a[0]", "a[1]", "a[2]", "a[3]", "a[4]"};
LinkedList<String> list=new LinkedList<String>();
for (String x :arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[4], a[3] ,a[2], a[0]");
System.out.println(list);

}

}

b9933036 提到...

String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList<String> list=new LinkedList<String>(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list);

B9933010 提到...

package p1;
import java.util.*;
public class b1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub



String arr[]={"a[0]", "a[1]", "a[2]","a[3]","a[4]"};
LinkedList< String > list= new LinkedList< String >();
for (String x :arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[0],a[1],a[2],a[3],a[4]");
System.out.println(list);
}
}

b9933025 提到...

package pack1;
import java.util.*;
public class t1 {


public static void main(String[] args) {
String arr[]={"a[0]", "a[1]", "a[2]","a[3]","a[4]"};
LinkedList< String > list= new LinkedList< String >();
for (String x :arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[0], a[1], a[2],a[3],a[4]");

System.out.println(list);

}
}

B9933017 提到...

package p1;
import java.util.*;
public class B1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String arr[]={"a[0]", "a[1]", "a[2]", "a[3]", "a[4]"};
LinkedList<String> list=new LinkedList<String>();
for (String x :arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[4], a[3] ,a[2], a[0]");
System.out.println(list);

}

}

B9933057 提到...

String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList<String> list=new LinkedList<String>(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list);

B9933053 提到...

package p1;
import java.util.*;
public class B1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String arr[]={"a[0]", "a[1]", "a[2]", "a[3]", "a[4]"};
LinkedList<String> list=new LinkedList<String>();
for (String x :arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[4], a[3] ,a[2], a[0]");
System.out.println(list);

}

}

B9933001 提到...

package A11;
import java.util.*;
public class A11 {


public static void main(String[] args) {

String arr[]={"YA", "拉", "嘻","u","dk" };
LinkedList< String > list= new LinkedList< String >();
for (String x :arr)
list.addFirst(x);


list.remove(3);

int x=list.indexOf("dk");
if (x!=-1)
list.add(x,"YA,嘻,u,dk" );

System.out.println(list);



}

}

b9933028 提到...

package a1;
import java.util.*;
public class p1 {
public static void main(String[] args) {
String arr[]={"a[0]", "a[1]", "a[2]", "a[3]", "a[4]"};
LinkedList< String > list= new LinkedList< String >();
for (String x :arr)
list.add(x);
list.remove("a[3]");
list.add("a[4]");
list.add("a[3]");
list.add("a[2]");
list.add("a[0]");
System.out.println(list);
}

}

b9933028 提到...

package a1;
import java.util.*;
public class p1 {
public static void main(String[] args) {
String arr[]={"a[0]", "a[1]", "a[2]", "a[3]", "a[4]"};
LinkedList< String > list= new LinkedList< String >();
for (String x :arr)
list.add(x);
list.remove("a[3]");
list.add("a[4]");
list.add("a[3]");
list.add("a[2]");
list.add("a[0]");
System.out.println(list);
}

}

b9933014 提到...

package V1;
import java.util.*;
public class 12A {
public static void main(String[] args) {
Stringarr[]={“a[0]”, “a[1]”, “a[2]”, “a[3]”, “a[4]”};
LinkedList&lt<String> list=new LinkedList&lt<String>();
for(String x :arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,&quot;a[4], a[3], a[2], a[0]);
System.out.println(list);
}
}

b9933016 提到...

import java.util.*;
class test1114
{
public static void main(String[] args)
{
String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"};

LinkedList<String> list=new LinkedList<String>();


list.add("a[4]");
list.add("a[3]");
list.add("a[2]");
list.add("a[0]");

System.out.print(list);

}
}

b9933005豐智偉 提到...

package P1 ;
import java.util.*;
class A{
public static void main(String[] args)
{
String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"};
LinkedList<String> list=new LinkedList<String>();
for(String x:arr)
list.add(x);
list.remove(3);
list.add("a[4]");
list.add("a[3]");
list.add("a[2]");
list.add("a[0]");
System.out.print(list);
}
}

b9933024 提到...

import java.util.*;
public class B9933024 {
[public static void main(String[] args)
[{
[[String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"};
LinkedList<String> list=new LinkedList<String>();
for(String x:arr)
[[list.add(x);
list.remove(3);
list.add("a[4]");
[[list.add("a[3]");
[[list.add("a[2]");
[[list.add("a[0]");
[System.out.print(list);
}
}

B9933006 提到...

import java.util.*;
public class A2
{
public static void main(String[] args)
{
String arr[]={ "喜", "怒", "哀", "樂", "嘆" };
LinkedList< String > list= new LinkedList< String >();
for (String x :arr)
list.addFirst(x);

list.remove(3);

int x=list.indexOf("嘆");

if (x!=-1)
list.add(x,"喜, 怒, 哀, 嘆" );

System.out.println(list);
}
}

B9933051 提到...

import java.util.*;
public class B9933051
{
public static void main(String[] args)
{
String arr[]={"I","YOU","SHE","HE","IT"};

LinkedList<String> list=new LinkedList<String>();

for(String x:arr)
list.add(x);

list.remove(3);

list.add("IT");
list.add("HE");
list.add("SHE");
list.add("I");

System.out.print(list);

}
}

B9933043 提到...

package pack1;
import java.util.*;
public class A1 {


public static void main(String[] args) {
String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"};
LinkedList< String > list= new LinkedList< String >();
for (String x :arr)
list.add(x);
list.remove(3);
int y=4;
list.add(y,"a[4], a[3], a[2], a[0]");
System.out.println(list);

}

}

b9733054 提到...

import java.util.*;

class b9733054
{
public static void main(String[] args)
{
String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"};

LinkedList<String> list=new LinkedList<String>();

for(String x:arr)
list.add(x);

list.remove(3);

list.add("a[4]");
list.add("a[3]");
list.add("a[2]");
list.add("a[0]");

System.out.print(list);

}
}

B9933015 提到...

package B1; import java.util.*; public class D { public static void main(String[] args) { String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList<String> list=new LinkedList<String>(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list); } }

B9933015 提到...

package B1; import java.util.*; public class D { public static void main(String[] args) { String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList<String> list=new LinkedList<String>(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list); } }

B9933015 提到...

package B1; import java.util.*; public class D { public static void main(String[] args) { String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList<String> list=new LinkedList<String>(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list); } }

B9933020 提到...

package A3;
import java.util.*;
public class A5 {
public static void main(String[] args) { String arr[]={&quot;a[0]&quot;,&quot;a[1]&quot;,&quot;a[2]&quot;,&quot;a[3]&quot;,&quot;a[4]&quot;}; LinkedList&lt;String&gt; list=new LinkedList&lt;String&gt;(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,&quot;a[4], a[3], a[2], a[0]&quot;); System.out.println(list); } }

B9933020 提到...

package A3;
import java.util.*;
public class A5 {
public static void main(String[] args) { String arr[]={&quot;a[0]&quot;,&quot;a[1]&quot;,&quot;a[2]&quot;,&quot;a[3]&quot;,&quot;a[4]&quot;}; LinkedList&lt;String&gt; list=new LinkedList&lt;String&gt;(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,&quot;a[4], a[3], a[2], a[0]&quot;); System.out.println(list); } }.

Z1001012 提到...

String arr[]={"a[0]","a[1]","a[2]","a[3]","a[4]"}; LinkedList list=new LinkedList(); for(String x:arr) list.add(x); list.remove(3); int y=4; list.add(y,"a[4], a[3], a[2], a[0]"); System.out.println(list);

Related Posts Plugin for WordPress, Blogger...

熱門文章