welcome: please sign in
location: "リスト処理の演習"の差分
10と11のリビジョン間の差分
2010-11-15 12:44:16時点のリビジョン10
サイズ: 418
編集者: masahiko
コメント:
2010-11-15 12:54:09時点のリビジョン11
サイズ: 760
編集者: masahiko
コメント:
削除された箇所はこのように表示されます。 追加された箇所はこのように表示されます。
行 5: 行 5:

 {{{#!java
public class Chain
{
 Chain next;

 void show()
 {
  System.out.println(this);
 }

 void showAll()
 {
  Chain c;

  c = this;
  System.out.println("(");
  while(c != null)
  {
   c.show();
   c = c.next;
  }
  System.out.println(")");
 }
 
 public static void main(String[] args)
 {
  ...
 }
}
 }}}

課題07

Chainクラスを作成し、次のいずれかを行うmainメソッドを記述しなさい。

  •    1 public class Chain
       2 {
       3         Chain next;
       4 
       5         void show()
       6         {
       7                 System.out.println(this);
       8         }
       9 
      10         void showAll()
      11         {
      12                 Chain c;
      13 
      14                 c = this;
      15                 System.out.println("(");
      16                 while(c != null)
      17                 {
      18                         c.show();
      19                         c = c.next;
      20                 }
      21                 System.out.println(")");
      22         }
      23         
      24         public static void main(String[] args)
      25         {
      26                 ...
      27         }
      28 }
    


1. (初級)


2. (中級)

初級と同じ動作をさせるのに、 next.next のような記述をしないで行いなさい。


3. (上級)

初級で作成しているインスタンスを次の順で作成するようにしなさい。

リスト処理の演習 (最終更新日時 2012-03-27 05:02:27 更新者 masahiko)