ALG2012-A.ppt

Size: px
Start display at page:

Download "ALG2012-A.ppt"

Transcription

1

2 (, )ε

3

4 m = n C2 = n ( n 1) / 2 m = n ( n 1)

5

6 dimentional binary hyper cube

7 ......

8 public class Node<E> { private E value; // private Collection<Node<E>> edges; // private boolean visited; private int sequence; private boolean searching; public Node(E value, Collection<Node<E>> edges) { this.value = value; this.edges = edges; reset(); public void reset(){ this.visited = false; this.sequence = ; this.edges.clear(); this.searching = false; public E getvalue() { // return value; public Collection<Node<E>> getedges(){ return this.edges; public boolean isvisited() { return visited; public void setvisited(boolean v) { this.visited = v; public int getsequence() { return sequence; public void setsequence(int s) { this.sequence = s; public boolean issearching() { return searching; public void setsearching(boolean s) { this.searching = s; public void connect(node<e> to){ this.edges.add(to); // if(!to.getedges().contains(this) ){ to.getedges().add(this); public void connectto(node<e> to){ this.edges.add(to); // 8

9 private static Node<Character> nodea = new Node<Character>('A', new LinkedList<Node<Character>>()); private static Node<Character> nodeb = new Node<Character>('B', new LinkedList<Node<Character>>()); private static Node<Character> nodec = new Node<Character>('C', new LinkedList<Node<Character>>()); private static Node<Character> noded = new Node<Character>('D', new LinkedList<Node<Character>>()); private static Node<Character> nodee = new Node<Character>('E', new LinkedList<Node<Character>>()); private static Node<Character> nodef = new Node<Character>('F', new LinkedList<Node<Character>>()); private static Node<Character> nodeg = new Node<Character>('G', new LinkedList<Node<Character>>()); private static Collection<Node<Character>> test_data = new LinkedList<Node<Character>>(); static { test_data.add(nodea); test_data.add(nodeb); test_data.add(nodec); test_data.add(noded); test_data.add(nodee); test_data.add(nodef); test_data.add(nodeg); public class DepthFirstSearch { private static <E> void visit(node<e> node){ node.setvisited(true); System.out.print(node.getValue()); for(node<e> neighbor: node.getedges()){ if(neighbor.isvisited()) continue; // System.out.print(" -> "); visit(neighbor); public static <E> void search(collection<node<e>> graph){ for(node<e> node: graph){ if(node.isvisited()) continue; // System.out.println(node.getValue() + ""); visit(node); System.out.println(); 9

10 public static void main(string[] args) { System.out.println("4.3.2"); for(node<character> node: test_data){ node.reset(); nodea.connect(nodec); nodea.connect(noded); nodea.connect(nodeb); nodec.connect(nodee); nodec.connect(nodef); noded.connect(nodeb); noded.connect(nodef); nodee.connect(nodeg); nodee.connect(nodef); search(test_data); public static void main(string[] args) { System.out.println("4.3.3"); for(node<character> node: test_data){ node.reset(); nodea.connect(nodec); nodea.connect(noded); nodea.connect(nodeb); nodec.connect(nodef); nodec.connect(nodee); noded.connect(nodeb); noded.connect(nodef); nodee.connect(nodeg); nodee.connect(nodef); search(test_data); public static void main(string[] args) { System.out.println("4.3.4"); for(node<character> node: test_data){ node.reset(); nodea.connectto(nodec); nodea.connectto(noded); nodea.connectto(nodee); nodec.connectto(nodeb); nodeb.connectto(nodea); noded.connectto(nodec); noded.connectto(nodee); nodef.connectto(nodea); nodef.connectto(nodeg); search(test_data); 1

11 ....

12 public class DirectedDepthFirstSearch<E> { private int sequence; private void visit(node<e> node){ node.setvisited(true); node.setsequence(++this.sequence); node.setsearching(true); System.out.print(node.getValue()); for(node<e> neighbor: node.getedges()){ if(neighbor.getsequence() == ){ System.out.print(" -> "); visit(neighbor); // else if (neighbor.getsequence() > node.getsequence()) { System.out.print(" (" + node.getvalue() + ", " + neighbor.getvalue() + ")"); else if (neighbor.issearching()){ System.out.print(" (" + node.getvalue() + ", " + neighbor.getvalue() + ")"); else { System.out.print(" (" + node.getvalue() + ", " + neighbor.getvalue() + ")"); node.setsearching(false); public void search(collection<node<e>> graph){ this.sequence = ; for(node<e> node: graph){ if(node.getsequence() == ){ System.out.println(node.getValue() + ""); visit(node); System.out.println(); 12

13 public static void main(string[] args) { System.out.println("4.3.4"); for(node<character> node: test_data){ node.reset(); nodea.connectto(nodec); nodea.connectto(noded); nodea.connectto(nodee); nodec.connectto(nodeb); nodeb.connectto(nodea); noded.connectto(nodec); noded.connectto(nodee); nodef.connectto(nodea); nodef.connectto(nodeg); new DirectedDepthFirstSearch<Character>().search(test_data); 13

14

15 ....

16 public class BreadthFirstSearch { public static <E> void search(collection<node<e>> graph){ Queue<Node<E>> queue = new LinkedList<Node<E>>(); for(node<e> node: graph){ if(node.isvisited()){ continue; // queue.add(node); node.setvisited(true); while(!queue.isempty() ){ Node<E> next = queue.remove(); System.out.print("" + next.getvalue()); for(node<e> neighbor: next.getedges()){ if( neighbor.isvisited() ){ continue; // FIFO // enqueue // dequeue queue.add(neighbor); // enqueue neighbor.setvisited(true); System.out.print(" (" + next.getvalue() + ", " + neighbor.getvalue() + ")"); System.out.print(" -> "); System.out.println(); 16

17 public static void main(string[] args) { System.out.println("4.3.7"); for(node<character> node: test_data){ node.reset(); nodea.connect(nodec); nodea.connect(noded); nodea.connect(nodeb); nodec.connect(nodee); nodec.connect(nodef); noded.connect(nodeb); noded.connect(nodef); nodee.connect(nodeg); nodee.connect(nodef); search(test_data); 17

18 public class DepthFirstSearchStack { public static <E> void search(collection<node<e>> graph){ Stack<Node<E>> stack = new Stack<Node<E>>(); for(node<e> node: graph){ if(node.isvisited()){ continue; // stack.push(node); node.setvisited(true); while(!stack.empty() ){ Node<E> next = stack.pop(); System.out.print("" + next.getvalue()); for(node<e> neighbor: next.getedges()){ if( neighbor.isvisited() ){ continue; stack.add(neighbor); neighbor.setvisited(true); System.out.print(" -> "); System.out.println(); // LIFO // push // pop // push 18

untitled

untitled 21174 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/211/index.html tech.ac.jp/k1sakai/lecture/alg/211/index.html html (, )ε m = n C2 = n ( n 1) / 2 m = n ( ( n

More information

ALG2012-C.ppt

ALG2012-C.ppt 2012717 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2012/index.html 1 1. 2. 2 .. 3 public class WeightedNode { private E value; // private Map

More information

アルゴリズムとデータ構造1

アルゴリズムとデータ構造1 1 2005 7 22 22 (sakai.keiichi@kochi sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2005/index.html tech.ac.jp/k1sakai/lecture/alg/2005/index.html f(0) = 1, f(x) =

More information

ALG ppt

ALG ppt 2012 6 21 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2012/index.html 1 l l O(1) l l l 2 (123 ) l l l l () l H(k) = k mod n (k:, n: ) l l 3 4 public class MyHashtable

More information

8 if switch for while do while 2

8 if switch for while do while 2 (Basic Theory of Information Processing) ( ) if for while break continue 1 8 if switch for while do while 2 8.1 if (p.52) 8.1.1 if 1 if ( ) 2; 3 1 true 2 3 false 2 3 3 8.1.2 if-else (p.54) if ( ) 1; else

More information

untitled

untitled 2011 6 20 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2011/index.html tech.ac.jp/k1sakai/lecture/alg/2011/index.html html 1 O(1) O(1) 2 (123) () H(k) = k mod n

More information

( ) ( ) 30 ( ) 27 [1] p LIFO(last in first out, ) (push) (pup) 1

( ) ( ) 30 ( ) 27 [1] p LIFO(last in first out, ) (push) (pup) 1 () 2006 2 27 1 10 23 () 30 () 27 [1] p.97252 7 2 2.1 2.1.1 1 LIFO(last in first out, ) (push) (pup) 1 1: 2.1.2 1 List 4-1(p.100) stack[] stack top 1 2 (push) (pop) 1 2 void stack push(double val) val stack

More information

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value = Part2-1-3 Java (*) (*).class Java public static final 1 class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value

More information

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value = Part2-1-3 Java (*) (*).class Java public static final 1 class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value

More information

untitled

untitled 2011 7 21 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2011/index.html tech.ac.jp/k1sakai/lecture/alg/2011/index.html html 1 5 2 3 4 - 5 .. 6 - 7 public class KnapsackBB

More information

Microsoft Word - keisankigairon.ch doc

Microsoft Word - keisankigairon.ch doc 1000000100001010 1000001000001011 0100001100010010 1010001100001100 load %r1,10 load %r2,11 add %r3,%r1,%r2 store %r3,12 k = i + j ; = > (* 1 2 3 4 5 6 7 8 9 10) 3628800 DO 3 I=1,3 DO3I=1.3 DO3I 1.3

More information

明解Javaによるアルゴリズムとデータ構造

明解Javaによるアルゴリズムとデータ構造 21 algorithm List 1-1 a, b, c max Scanner Column 1-1 List 1-1 // import java.util.scanner; class Max3 { public static void main(string[] args) { Scanner stdin = new Scanner(System.in); Chap01/Max3.java

More information

ALG2012-F.ppt

ALG2012-F.ppt 2012 7 26 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2012/index.html 5 2 3 4 - 5 .. 6 - 7 public class KnapsackBB { // 0-1 private static double maxsofar; private

More information

明解Javaによるアルゴリズムとデータ構造

明解Javaによるアルゴリズムとデータ構造 74 searching 3 key Fig.3-1 75 2を探索 53を探索 3-1 5 2 1 4 3 7 4 を探索 Fig.3-1 76 3 linear searchsequential search 2 Fig.3-2 0 ❶ ❷ ❸ 配列の要素を先頭から順に走査していく 探索すべき値と等しい要素を発見 Fig.3-2 6 4 3 2 3-2Fig.3-3 77 5 Fig.3-3 0

More information

: : : TSTank 2

: : : TSTank 2 Java (8) 2008-05-20 Lesson6 Lesson5 Java 1 Lesson 6: TSTank1, TSTank2, TSTank3 java 2 car1 car2 Car car1 = new Car(); Car car2 = new Car(); car1.setcolor(red); car2.setcolor(blue); car2.changeengine(jet);

More information

アルゴリズムとデータ構造1

アルゴリズムとデータ構造1 1 200972 (sakai.keiichi@kochi sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi ://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2009/index.html 29 20 32 14 24 30 48 7 19 21 31 Object public class

More information

K227 Java 2

K227 Java 2 1 K227 Java 2 3 4 5 6 Java 7 class Sample1 { public static void main (String args[]) { System.out.println( Java! ); } } 8 > javac Sample1.java 9 10 > java Sample1 Java 11 12 13 http://java.sun.com/j2se/1.5.0/ja/download.html

More information

アルゴリズムとデータ構造1

アルゴリズムとデータ構造1 1 2007 6 26 26 (sakai.keiichi@kochi sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2007/index.html tech.ac.jp/k1sakai/lecture/alg/2007/index.html FIFO (46 ) head,

More information

新・明解Javaで学ぶアルゴリズムとデータ構造

新・明解Javaで学ぶアルゴリズムとデータ構造 第 3 章 探索 Arrays.binarySearch 743 3-1 探索 探索 searching key 配列 探索 Fig.3-1 b c 75 a 6 4 3 2 1 9 8 2 b 64 23 53 65 75 21 3-1 53 c 5 2 1 4 3 7 4 Fig.3-1 a 763 3-2 線形探索 線形探索 linear search sequential search 2

More information

Java (7) Lesson = (1) 1 m 3 /s m 2 5 m 2 4 m 2 1 m 3 m 1 m 0.5 m 3 /ms 0.3 m 3 /ms 0.6 m 3 /ms 1 1 3

Java (7) Lesson = (1) 1 m 3 /s m 2 5 m 2 4 m 2 1 m 3 m 1 m 0.5 m 3 /ms 0.3 m 3 /ms 0.6 m 3 /ms 1 1 3 Java (7) 2008-05-20 1 Lesson 5 1.1 5 3 = (1) 1 m 3 /s 1 2 3 10 m 2 5 m 2 4 m 2 1 m 3 m 1 m 0.5 m 3 /ms 0.3 m 3 /ms 0.6 m 3 /ms 1 1 3 1.2 java 2 1. 2. 3. 4. 3 2 1.3 i =1, 2, 3 V i (t) 1 t h i (t) i F, k

More information

r1.dvi

r1.dvi 2006 1 2006.10.6 ( 2 ( ) 1 2 1.5 3 ( ) Ruby Java Java Java ( Web Web http://lecture.ecc.u-tokyo.ac.jp/~kuno/is06/ / ( / @@@ ( 3 ) @@@ : ( ) @@@ (Q&A) ( ) 1 http://www.sodan.ecc.u-tokyo.ac.jp/cgi-bin/qbbs/view.cgi

More information

I java A

I java A I java 065762A 19.6.22 19.6.22 19.6.22 1 1 Level 1 3 1.1 Kouza....................................... 3 1.2 Kouza....................................... 4 1.3..........................................

More information

Microsoft Word - NonGenList.doc

Microsoft Word - NonGenList.doc ジェネリクスとコンパレータを使用しないリストのプログラム例 1. ポインタによる線形リスト LinkedListNG.java: ポインタによる線形リストのクラス LinkedListNG LinkedListTesterNG.java: LinkedListNG を利用するプログラム例 2. カーソルによる線形リスト AryLinkedListNG.java: カーソルによる線形リストのクラス AryLinkedListNG

More information

text_08.dvi

text_08.dvi C 8 12 6 6 8 Java (3) 1 8.1 8 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 8.2 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

More information

2. データ構造ヒープに保存するデータは 番号付けられて保存される 従って リスト L として保存することとする 3. アルゴリズム 3.1. 要素の追加新しい要素の追加は リストの終端に置くことで開始する つまり 最下層の一番右 または新たに最下層を生成してその一番左となる この後 この要素を正し

2. データ構造ヒープに保存するデータは 番号付けられて保存される 従って リスト L として保存することとする 3. アルゴリズム 3.1. 要素の追加新しい要素の追加は リストの終端に置くことで開始する つまり 最下層の一番右 または新たに最下層を生成してその一番左となる この後 この要素を正し 1. はじめに 二分木ヒープ 様々なアルゴリズムにおいて ある要素の集合またはリストから 最小 な要素を取り 出す必要がある そのような場合に使われる標準的データ構造が二分木ヒープ (binary heap) である あるオブジェクトO を考える そのオブジェクトは ラベル O. label と値 O. value を持つとする このようなオブジェクトを保存する二分木ヒープについて考える 二分木ヒープは以下の二つの制約のある二分木である

More information

3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World");

3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println(Hello World); (Basic Theory of Information Processing) Java (eclipse ) Hello World! eclipse Java 1 3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello

More information

新・明解Javaで学ぶアルゴリズムとデータ構造

新・明解Javaで学ぶアルゴリズムとデータ構造 第 1 章 基本的 1 n 21 1-1 三値 最大値 algorithm List 1-1 a, b, c max // import java.util.scanner; class Max3 { public static void main(string[] args) { Scanner stdin = new Scanner(System.in); List 1-1 System.out.println("");

More information

1. はじめに 二分木ヒープ 様々なアルゴリズムにおいて ある要素の集合またはリストから 最小 な要素を取り 出す必要がある そのような場合に使われる標準的データ構造が二分木ヒープ (binary heap) である あるオブジェクトO を考える そのオブジェクトは ラベル O. label と値

1. はじめに 二分木ヒープ 様々なアルゴリズムにおいて ある要素の集合またはリストから 最小 な要素を取り 出す必要がある そのような場合に使われる標準的データ構造が二分木ヒープ (binary heap) である あるオブジェクトO を考える そのオブジェクトは ラベル O. label と値 1. はじめに 二分木ヒープ 様々なアルゴリズムにおいて ある要素の集合またはリストから 最小 な要素を取り 出す必要がある そのような場合に使われる標準的データ構造が二分木ヒープ (binary heap) である あるオブジェクトO を考える そのオブジェクトは ラベル O. label と値 O. value を持つ とする このようなオブジェクトを保存する二分木ヒープについて考える 二分木ヒープは以下の二つの制約のある二分木である

More information

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF pref : 2004/6/5 (11:8) pref : 2004/6/5 (11:8) pref : 2004/6/5 (11:8) 3 5 14 18 21 23 23 24 28 29 29 31 32 34 35 35 36 38 40 44 44 45 46 49 49 50 pref : 2004/6/5 (11:8) 50 51 52 54 55 56 57 58 59 60 61

More information

Microsoft Word - NonGenTree.doc

Microsoft Word - NonGenTree.doc ジェネリクスとコンパレータを使用しない 2 分探索木のプログラム例 BinTreeNG.java: 2 分探索木のクラス BinTreeNG BinTreeTesterNG.java: BinTreeNG を利用するプログラム例 === BinTreeNG.java =========================================================================

More information

10K pdf

10K pdf #1 #2 Java class Circle { double x; // x double y; // y double radius; // void set(double tx, double ty){ x = tx; y = ty; void set(double tx, double ty, double r) { x = tx; y = ty; radius = r; // Circle

More information

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1 Java (9) 1 Lesson 7 2008-05-20 Java System.out.println() 1 Java API 1 Java Java 1 GUI 2 Java 3 1.1 5 3 1.0 10.0, 1.0, 0.5 5.0, 3.0, 0.3 4.0, 1.0, 0.6 1 2 4 3, ( 2 3 2 1.2 Java (stream) 4 1 a 5 (End of

More information

新・明解Java入門

新・明解Java入門 537,... 224,... 224,... 32, 35,... 188, 216, 312 -... 38 -... 38 --... 102 --... 103 -=... 111 -classpath... 379 '... 106, 474!... 57, 97!=... 56 "... 14, 476 %... 38 %=... 111 &... 240, 247 &&... 66,

More information

Microsoft PowerPoint ppt

Microsoft PowerPoint ppt 独習 Java ( 第 3 版 ) 6.7 変数の修飾子 6.8 コンストラクタの修飾子 6.9 メソッドの修飾子 6.10 Object クラスと Class クラス 6.7 変数の修飾子 (1/3) 変数宣言の直前に指定できる修飾子 全部で 7 種類ある キーワード final private protected public static transient volatile 意味定数として使える変数同じクラスのコードからしかアクセスできない変数サブクラスまたは同じパッケージ内のコードからしかアクセスできない変数他のクラスからアクセスできる変数インスタンス変数ではない変数クラスの永続的な状態の一部ではない変数不意に値が変更されることがある変数

More information

JAVA とテンプレート

JAVA とテンプレート JAVA とテンプレート 序論 : コンテナ 他のクラスのオブジェクトを保存するものをコンテナ (Container) と呼ぶ 集合 リスト 表 コンテナに求められる機能 追加 削除 参照 要素の比較 並べ替え 要素のクラスが不明では 比較できない 要素が想定しているクラスのものかの判定 テンプレート以前の対応方法 コンテナ設計時に 保存されるクラスを特定してコンテナをコードする 保存されるクラスごとに作成しなければならない

More information

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 条件判断文 3 switch 文 switch 文式が case の値と一致した場合 そこから直後の break; までを処理し どれにも一致しない場合 default; から直後の break; までを処理する 但し 式や値 1

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 条件判断文 3 switch 文 switch 文式が case の値と一致した場合 そこから直後の break; までを処理し どれにも一致しない場合 default; から直後の break; までを処理する 但し 式や値 1 Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 条件判断文 3 switch 文 switch 文式が case の値と一致した場合 そこから直後の までを処理し どれにも一致しない場合 default; から直後の までを処理する 但し 式や値 1 値 2は整数または文字である switch( 式 ) case 値 1: // コロン : です セミコロン ; と間違えないように!!

More information

問題 01 以下は コンソールより年齢を入力させ その年齢にあった料金を表示するプログラムである 年齢ごとの金額は以下の通りである 年齢の範囲金額 0 歳以上 6 歳以下 120 円 7 歳以上 65 歳未満 200 円 65 歳以上無料 package j1.exam02; import java

問題 01 以下は コンソールより年齢を入力させ その年齢にあった料金を表示するプログラムである 年齢ごとの金額は以下の通りである 年齢の範囲金額 0 歳以上 6 歳以下 120 円 7 歳以上 65 歳未満 200 円 65 歳以上無料 package j1.exam02; import java 問題 01 以下は コンソールより年齢を入力させ その年齢にあった料金を表示するプログラムである 年齢ごとの金額は以下の通りである 年齢の範囲金額 0 歳以上 6 歳以下 120 円 7 歳以上 65 歳未満 200 円 65 歳以上無料 public class Ex0201 { System.out.print("input> "); int input = Integer.parseInt(reader.readLine());

More information

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の break; まで処理しますどれにも一致致しない場合 def

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の break; まで処理しますどれにも一致致しない場合 def Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の まで処理しますどれにも一致致しない場合 default: から直後の まで処理します 式の結果 ラベル 定数 整数または文字 (byte, short, int,

More information

2

2 問題 次の設問に答えよ 設問. Java のソースコードをコンパイルするコマンドはどれか a) java b) javac c) javadoc d) javaw 設問. Java のバイトコード ( コンパイル結果 ) を実行するコマンドはどれか a) java b) javac c) javadoc d).jar 設問. Java のソースコードの拡張子はどれか a).c b).java c).class

More information

Java (5) 1 Lesson 3: x 2 +4x +5 f(x) =x 2 +4x +5 x f(10) x Java , 3.0,..., 10.0, 1.0, 2.0,... flow rate (m**3/s) "flow

Java (5) 1 Lesson 3: x 2 +4x +5 f(x) =x 2 +4x +5 x f(10) x Java , 3.0,..., 10.0, 1.0, 2.0,... flow rate (m**3/s) flow Java (5) 1 Lesson 3: 2008-05-20 2 x 2 +4x +5 f(x) =x 2 +4x +5 x f(10) x Java 1.1 10 10 0 1.0 2.0, 3.0,..., 10.0, 1.0, 2.0,... flow rate (m**3/s) "flowrate.dat" 10 8 6 4 2 0 0 5 10 15 20 25 time (s) 1 1

More information

ただし 無作為にスレッドを複数実行すると 結果不正やデッドロックが起きる可能性がある 複数のスレッド ( マルチスレッド ) を安全に実行する ( スレッドセーフにする ) ためには 同期処理を用いるこ とが必要になる 同期処理は 予約語 synchronized で行うことができる ここでは sy

ただし 無作為にスレッドを複数実行すると 結果不正やデッドロックが起きる可能性がある 複数のスレッド ( マルチスレッド ) を安全に実行する ( スレッドセーフにする ) ためには 同期処理を用いるこ とが必要になる 同期処理は 予約語 synchronized で行うことができる ここでは sy オブジェクト指向プログラミング演習 2010/10/27 演習課題 スレッド ( その 2) 同期処理 結果不正 デッドロック 前回のスレッドの演習では 複数のスレッドを実行し 一つのプログラムの中の違う処理を同時に実行し た ただし 無作為にスレッドを複数実行すると 結果不正やデッドロックが起きる可能性がある 複数のスレッド ( マルチスレッド ) を安全に実行する ( スレッドセーフにする )

More information

$ java StoreString abc abc ed abced twice abcedabced clear xyz xyz xyz bingo! abc bingo!abc ^Z mport java.io.*; ublic class StoreString { public static void main(string[] args) throws IOException{ BufferedReader

More information

(Eclipse\202\305\212w\202\324Java2\215\374.pdf)

(Eclipse\202\305\212w\202\324Java2\215\374.pdf) C H A P T E R 11 11-1 1 Sample9_4 package sample.sample11; public class Sample9_4 { 2 public static void main(string[] args) { int[] points = new int[30]; initializearray(points); double averagepoint =

More information

ALG ppt

ALG ppt 2012614 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2012/index.html 1 2 2 3 29 20 32 14 24 30 48 7 19 21 31 4 N O(log N) 29 O(N) 20 32 14 24 30 48 7 19 21 31 5

More information

問 次の Fortran プログラムの説明及びプログラムを読んで、設問に答えよ。

問 次の Fortran プログラムの説明及びプログラムを読んで、設問に答えよ。 解答例 問題 1 変数 a が 3 以上でかつ 7 以下の場合 true と表示し そうでない場合は false と表示するプログラムである public class Prog061004_01 { int a; boolean b; a = Integer.parseInt(buf.readLine()); b = (a >= 3) && (a

More information

解きながら学ぶJava入門編

解きながら学ぶJava入門編 44 // class Negative { System.out.print(""); int n = stdin.nextint(); if (n < 0) System.out.println(""); -10 Ÿ 35 Ÿ 0 n if statement if ( ) if i f ( ) if n < 0 < true false true false boolean literalboolean

More information

Vector Vector Vector Vector() Vector(int n) n Vector(int n,int delta) n delta

Vector Vector Vector Vector() Vector(int n) n Vector(int n,int delta) n delta Java VectorEnumeration Stack Hashtable StringTokenizer Vector Vector Vector Vector() Vector(int n) n Vector(int n,int delta) n delta Vector Vector void addelement(object obj) int capacity() Object clone()

More information

Exam : 1z1-809-JPN Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z1-809-JPN Exam's Question and Answers 1 from Ac

Exam : 1z1-809-JPN Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z1-809-JPN Exam's Question and Answers 1 from Ac Actual4Test http://www.actual4test.com Actual4test - actual test exam dumps-pass for IT exams Exam : 1z1-809-JPN Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z1-809-JPN

More information

r02.dvi

r02.dvi 172 2017.7.16 1 1.1? X A B A X B ( )? IBMPL/I FACOM PL1 ( ) X ( ) 1.2 1 2-0 ( ) ( ) ( ) (12) ( ) (112) (131) 281 26 1 (syntax) (semantics) ( ) 2 2.1 BNF BNF(Backus Normal Form) Joun Backus (grammer) English

More information

ohp02.dvi

ohp02.dvi 172 2017.7.16 1 ? X A B A X B ( )? IBMPL/I FACOM PL1 ( ) X 2 ( ) 3 2-0 ( ) ( ) ( ) (12) ( ) (112) 31) 281 26 1 4 (syntax) (semantics) ( ) 5 BNF BNF(Backus Normal Form) Joun Backus (grammer) English grammer

More information

Java演習(4) -- 変数と型 --

Java演習(4)   -- 変数と型 -- 50 20 20 5 (20, 20) O 50 100 150 200 250 300 350 x (reserved 50 100 y 50 20 20 5 (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics; (reserved public class Blocks1 extends

More information

** 平成 16 年度 FE 午後問題 Java** 示現塾プロジェクトマネージャ テクニカルエンジニア ( ネットワーク ) など各種セミナーを開催中!! 開催日 受講料 カリキュラム等 詳しくは 今すぐアクセス!! 平成 16

** 平成 16 年度 FE 午後問題 Java** 示現塾プロジェクトマネージャ テクニカルエンジニア ( ネットワーク ) など各種セミナーを開催中!! 開催日 受講料 カリキュラム等 詳しくは   今すぐアクセス!! 平成 16 平成 16 年度春期 FE 午後問題 Java 問 8 次の Java プログラムの説明及びプログラムを読んで, 設問に答えよ プログラムの説明 このプログラムは, 数量の単位変換を行う共通機能を提供するクラス群と, それらのテストプログラムからなる テストプログラムでは, セルシウス温度 ( セ氏温度, ) 及びカ氏温度 ( F ) の変換を行うクラスを利用する (1) インタフェース Converter

More information

問題1 以下に示すプログラムは、次の処理をするプログラムである

問題1 以下に示すプログラムは、次の処理をするプログラムである 問題 1 次に示すプログラムは 配列 a の値を乱数で設定し 配列 a の値が 333 より大きく 667 以下の値 の合計値を求めるプログラムである 1 と 2 に適切なコードを記述してプログラムを完 成させよ class TotalNumber { public static void main(string[] args) { int[] a = new int[1000]; // 1 解答条件

More information

oop1

oop1 public class Car{ int num; double gas; // double distance; String maker; // // // void drive(){ System.out.println(""); Car.java void curve(){ System.out.println(""); void stop(){ System.out.println("");

More information

プログラミングA

プログラミングA プログラミング A 第 10 回 演習 2015 年 6 月 29 日 東邦大学金岡晃 本日の内容 中間テストの解説 演習 1 2015/6/29 プログラミング A 中間テスト解説 : 問 1 < 問 1> 下記の命令が実行された後の a の値を書きなさい ( 省略 ). int a=13; 答え : 13 2 中間テスト解説 : 問 2 < 問 2> 下記の命令が実行された後の a の値を書きなさい

More information

Java講座

Java講座 ~ 第 1 回 ~ 情報科学部コンピュータ科学科 2 年竹中優 プログラムを書く上で Hello world 基礎事項 演算子 構文 2 コメントアウト (//, /* */, /** */) をしよう! インデントをしよう! 変数などにはわかりやすい名前をつけよう! 要するに 他人が見て理解しやすいコードを書こうということです 3 1. Eclipse を起動 2. ファイル 新規 javaプロジェクト

More information

tkk0408nari

tkk0408nari SQLStatement Class Sql Database SQL Structured Query Language( ) ISO JIS http://www.techscore.com/tech/sql/02_02.html Database sql Perl Java SQL ( ) create table tu_data ( id integer not null, -- id aid

More information

break 文 switch ブロック内の実行中の処理を強制的に終了し ブロックから抜けます switch(i) 強制終了 ソースコード例ソースファイル名 :Sample7_1.java // 入力値の判定 import java.io.*; class Sample7_1 public stati

break 文 switch ブロック内の実行中の処理を強制的に終了し ブロックから抜けます switch(i) 強制終了 ソースコード例ソースファイル名 :Sample7_1.java // 入力値の判定 import java.io.*; class Sample7_1 public stati Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の まで処理しますどれにも一致しない場合 default: から直後の まで処理します 式は byte, short, int, char 型 ( 文字または整数 ) を演算結果としますラベルには整数リテラル

More information

二分木ヒープとは 集合 リストから 最小な 要素を取り出す 二分木ヒープは そのための標準的データ構造 二分木ヒープを保存するデータ構造 二分木ヒープの操作のメソッド 対象となるデータクラス 識別のためのlabelフィールド 値を保持するvalueフィールド

二分木ヒープとは 集合 リストから 最小な 要素を取り出す 二分木ヒープは そのための標準的データ構造 二分木ヒープを保存するデータ構造 二分木ヒープの操作のメソッド 対象となるデータクラス 識別のためのlabelフィールド 値を保持するvalueフィールド 二分木ヒープ (BINARY HEAP) 二分木ヒープとは 集合 リストから 最小な 要素を取り出す 二分木ヒープは そのための標準的データ構造 二分木ヒープを保存するデータ構造 二分木ヒープの操作のメソッド 対象となるデータクラス 識別のためのlabelフィールド 値を保持するvalueフィールド 二分木ヒープとは どういう二分木か ある頂点の要素 pのvalueは その子 cの要素のvalueより大きくない

More information

ALG ppt

ALG ppt 2012 7 5 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2012/index.html (198 ) f(p) p 2 1 2 f 2 53 12 41 69 11 2 84 28 31 63 97 58 76 19 91 88 53 69 69 11 84 84 63

More information

Javaによるアルゴリズムとデータ構造

Javaによるアルゴリズムとデータ構造 1 algorithm List 1-1 a, b, c List 1-1 // import java.util.scanner; class Max3 { public static void main(string[] args) { Scanner stdin = new Scanner(System.in); int a, b, c; int max; // Chap01/Max3.java

More information

{:from => Java, :to => Ruby } Java Ruby KAKUTANI Shintaro; Eiwa System Management, Inc.; a strong Ruby proponent http://kakutani.com http://www.amazon.co.jp/o/asin/4873113202/kakutani-22 http://www.amazon.co.jp/o/asin/477413256x/kakutani-22

More information

目的 泡立ち法を例に Comparableインターフェイスの実装 抽象クラスの利用 型パラメタの利用 比較 入替 の回数を計測

目的 泡立ち法を例に Comparableインターフェイスの実装 抽象クラスの利用 型パラメタの利用 比較 入替 の回数を計測 泡立ち法とその実装 計算機アルゴリズム特論 :2017 年度只木進一 目的 泡立ち法を例に Comparableインターフェイスの実装 抽象クラスの利用 型パラメタの利用 比較 入替 の回数を計測 Comparable インターフェイ ス クラスインスタンスが比較可能であることを示す Int compareto() メソッドを実装 Integer Double String などには実装済み public

More information

問題1 以下に示すプログラムは、次の処理をするプログラムである

問題1 以下に示すプログラムは、次の処理をするプログラムである 問題 1 次のプログラムの出力結果を a~d の中から選べ public class Problem1 { int i=2; int j=3; System.out.println("i"+j); a) 23,b) 5,c) i3,d) ij 問題 2 次のプログラムの出力結果を a~d の中から選べ public class Problem2 { int a=6; if((a>=2)&&(a

More information

#include #include #include int gcd( int a, int b) { if ( b == 0 ) return a; else { int c = a % b; return gcd( b, c); } /* if */ } int main() { int a = 60; int b = 45; int

More information

Java学習教材

Java学習教材 Java 2016/4/17 Java 1 Java1 : 280 : (2010/1/29) ISBN-10: 4798120987 ISBN-13: 978-4798120980 2010/1/29 1 Java 1 Java Java Java class FirstExample { public static void main(string[] args) { System.out.println("

More information

Microsoft PowerPoint - lec06 [互換モード]

Microsoft PowerPoint - lec06 [互換モード] 内 容 Ⅶ. クラスの定義 クラス定義の基本 フィールドの定義 メソッド定義 例題 : 円クラスのフィールドとメソッドの定義 コンストラクタ 例題 :Circle2を使ったアプレット 1 2 クラス定義の基本 オブジェクト指向のプログラム プログラム実行時に登場するオブジェクトの性質や挙動を記述する オブジェクトの性質や挙動を記述したものが クラス である Java プログラムを書くとはクラスを定義すること

More information

デジタル表現論・第4回

デジタル表現論・第4回 デジタル表現論 第 4 回 劉雪峰 ( リュウシュウフォン ) 2016 年 5 月 2 日 劉 雪峰 ( リュウシュウフォン ) デジタル表現論 第 4 回 2016 年 5 月 2 日 1 / 14 本日の目標 Java プログラミングの基礎 出力の復習 メソッドの定義と使用 劉 雪峰 ( リュウシュウフォン ) デジタル表現論 第 4 回 2016 年 5 月 2 日 2 / 14 出力 Systemoutprint()

More information

IE6 2 BMI chapter1 Java 6 chapter2 Java 7 chapter3 for if 8 chapter4 : BMI 9 chapter5 Java GUI 10 chapter6 11 chapter7 BMI 12 chap

IE6 2 BMI chapter1 Java 6 chapter2 Java 7 chapter3 for if 8 chapter4 : BMI 9 chapter5 Java GUI 10 chapter6 11 chapter7 BMI 12 chap 1-1 1-2 IE6 2 BMI 3-1 3-2 4 5 chapter1 Java 6 chapter2 Java 7 chapter3 for if 8 chapter4 : BMI 9 chapter5 Java GUI 10 chapter6 11 chapter7 BMI 12 chapter8 : 13-1 13-2 14 15 PersonTest.java KazuateGame.java

More information

2

2 問題 1 次の設問 1~5 に答えよ 設問 1. Java のソースプログラムをコンパイルするコマンドはどれか a) java b) javac c) javadoc d) jdb 設問 2. Java のバイトコード ( コンパイル結果 ) を実行するコマンドはどれか a) java b) javac c) javadoc d) jdb 設問 3. Java のソースプログラムの拡張子はどれか a).c

More information

Java updated

Java updated Java 2003.07.14 updated 3 1 Java 5 1.1 Java................................. 5 1.2 Java..................................... 5 1.3 Java................................ 6 1.3.1 Java.......................

More information

JavaプログラミングⅠ

JavaプログラミングⅠ Java プログラミング Ⅰ 6 回目 if 文と if else 文 今日の講義で学ぶ内容 関係演算子 if 文と if~else 文 if 文の入れ子 関係演算子 関係演算子 ==,!=, >, >=,

More information

r07.dvi

r07.dvi 19 7 ( ) 2019.4.20 1 1.1 (data structure ( (dynamic data structure 1 malloc C free C (garbage collection GC C GC(conservative GC 2 1.2 data next p 3 5 7 9 p 3 5 7 9 p 3 5 7 9 1 1: (single linked list 1

More information

ohp07.dvi

ohp07.dvi 19 7 ( ) 2019.4.20 1 (data structure) ( ) (dynamic data structure) 1 malloc C free 1 (static data structure) 2 (2) C (garbage collection GC) C GC(conservative GC) 2 2 conservative GC 3 data next p 3 5

More information

JavaプログラミングⅠ

JavaプログラミングⅠ Java プログラミング Ⅱ 4 回目クラスの機能 (2) コンストラクタ クラス変数 クラスメソッド課題 確認 問題次の各文は正しいか誤っているか答えなさい (1) コンストラクタはメソッドと同様に戻り値をもつ (2) コンストラクタはオブジェクトが生成されると最初に実行される (3) コンストラクタはメソッドと同様にオーバーロードができる (4) コンストラクタは常に public メンバとしなければならない

More information

PowerPoint Presentation

PowerPoint Presentation 幅優先探索アルゴリズム 復習 Javaでの実装 深さ優先探索 復習 Javaでの実装 1 探索アルゴリズムの一覧 問題を解決するための探索 幅優先探索 深さ優先探索 深さ制限探索 均一コスト探索 反復深化法 欲張り探索 山登り法 最良優先探索 2 Breadth-first search ( 幅優先探索 ) 探索アルゴリズムはノードやリンクからなる階層的なツリー構造で構成された状態空間を探索するアルゴリズムです

More information

プログラミング入門1

プログラミング入門1 プログラミング入門 1 第 5 回 繰り返し (while ループ ) 授業開始前に ログオン後 不要なファイルを削除し て待機してください Java 1 第 5 回 2 参考書について 参考書は自分にあったものをぜひ手元において自習してください 授業の WEB 教材は勉強の入り口へみなさんを案内するのが目的でつくられている これで十分という訳ではない 第 1 回に紹介した本以外にも良書がたくさんある

More information

Java 3 p.2 3 Java : boolean Graphics draw3drect fill3drect C int C OK while (1) int boolean switch case C Calendar java.util.calendar A

Java 3 p.2 3 Java : boolean Graphics draw3drect fill3drect C int C OK while (1) int boolean switch case C Calendar java.util.calendar A Java 3 p.1 3 Java Java if for while C 3.1 if Java if C if if ( ) 1 if ( ) 1 else 2 1 1 2 2 1, 2 { Q 3.1.1 1. int n = 2; if (n

More information

JavaプログラミングⅠ

JavaプログラミングⅠ Java プログラミング Ⅰ 3 回目変数 今日の講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能です 変数は 型 ( データ型ともいいます ) と識別子をもちます 2 型 変数に記憶できる値の種類です型は 値の種類に応じて次の 8 種類があり これを基本型といいます 基本型値の種類値の範囲または例 boolean 真偽値 true または

More information

Quick Sort 計算機アルゴリズム特論 :2017 年度 只木進一

Quick Sort 計算機アルゴリズム特論 :2017 年度 只木進一 Quick Sort 計算機アルゴリズム特論 :2017 年度 只木進一 2 基本的考え方 リスト ( あるいは配列 )SS の中の ある要素 xx(pivot) を選択 xx より小さい要素からなる部分リスト SS 1 xx より大きい要素からなる部分リスト SS 2 xx は SS 1 または SS 2 に含まれる 長さが 1 になるまで繰り返す pivot xx の選び方として 中央の要素を選択すると効率が良い

More information

Java プログラミング Ⅰ 3 回目変数 変数 変 数 一時的に値を記憶させておく機能型 ( データ型 ) と識別子をもつ 2 型 ( データ型 ) 変数の種類型に応じて記憶できる値の種類や範囲が決まる 型 値の種類 値の範囲 boolean 真偽値 true / false char 2バイト文

Java プログラミング Ⅰ 3 回目変数 変数 変 数 一時的に値を記憶させておく機能型 ( データ型 ) と識別子をもつ 2 型 ( データ型 ) 変数の種類型に応じて記憶できる値の種類や範囲が決まる 型 値の種類 値の範囲 boolean 真偽値 true / false char 2バイト文 Java プログラミング Ⅰ 3 回目変数 変数 変 数 一時的に値を記憶させておく機能型 ( データ型 ) と識別子をもつ 2 型 ( データ型 ) 変数の種類型に応じて記憶できる値の種類や範囲が決まる 型 値の種類 値の範囲 boolean 真偽値 true / false char 2バイト文字 0x0000 ~ 0xffff byte 1バイト整数 - 2 8 ~ 2 8-1 short 2バイト整数

More information

ワークショップ テスト駆動開発

ワークショップ テスト駆動開発 JUnit 5 5 20 20 FIT 20 FIT FIT 10 IT OO Web XML ADC2003 WG JUnit JUnit 3.8.1 URL: http://www.junit.org/index.htm junit.3.8.1.zip junit.jar c: junit junit.jar javac -classpath c: junit junit.jar JUnitTest.java

More information

Thread

Thread 14 2013 7 16 14.1....................................... 14 1 14.2 Thread................................... 14 1 14.3............................. 14 5 14.4....................................... 14 10

More information

JavaプログラミングⅠ

JavaプログラミングⅠ Java プログラミング Ⅰ 12 回目クラス 今日の講義で学ぶ内容 クラスとは クラスの宣言と利用 クラスの応用 クラス クラスとは 異なる複数の型の変数を内部にもつ型です 直観的に表現すると int 型や double 型は 1 1 つの値を管理できます int 型の変数 配列型は 2 5 8 6 3 7 同じ型の複数の変数を管理できます 配列型の変数 ( 配列変数 ) クラスは double

More information

問 次の Fortran プログラムの説明及びプログラムを読んで、設問に答えよ。

問 次の Fortran プログラムの説明及びプログラムを読んで、設問に答えよ。 ソフトウェア基礎演習課題 文法理解度確認範囲 問題 1 データ型 ( 変数, データ型 ) 問題 2 制御構造 (switch 文 ) 問題 3 制御構造 (while 文 ) 問題 4 制御構造と配列 ( 総和 ) 問題 5 制御構造と配列 ( 総和, 平均 ) 問題 6 データ型と各種演算子 ( 文字列, 検索 ) 問題 7 クラスの定義 ( メソッドの定義, コンストラクタの定義, キャスト

More information

明解Java入門編

明解Java入門編 1 Fig.1-1 4 Fig.1-1 1-1 1 Table 1-1 Ease of Development 1-1 Table 1-1 Java Development Kit 1 Java List 1-1 List 1-1 Chap01/Hello.java // class Hello { Java System.out.println("Java"); System.out.println("");

More information

1.1 (1) (2) (3) (4) 2

1.1 (1) (2) (3) (4) 2 1 Part2-1-1 1 1.1 (1) (2) (3) (4) 2 2 JAVA (*) Java : 1. Java 2. 3. 4. Java Java 3 3 int[] a; a = new int[3]; new int[3] a i a[i] 32bit a[i] 4 4 class Point { // double x, y, weight; // Point(double x,

More information

とても使いやすい Boost の serialization

とても使いやすい Boost の serialization とても使いやすい Boost の serialization Zegrahm シリアライズ ( 直列化 ) シリアライズ ( 直列化 ) とは何か? オブジェクトデータをバイト列や XML フォーマットに変換すること もう少しわかりやすく表現すると オブジェクトの状態を表す変数 ( フィールド ) とオブジェクトの種類を表す何らかの識別子をファイル化出来るようなバイト列 XML フォーマット形式で書き出す事を言う

More information

2

2 プログラミング応用演習 b 10 月 5 日演習課題 2016/10/05 PAb 演習課題 プログラム仕様書作成課題 課題クラスを読み 次に示すクラスの仕様書を完成させよ なお 仕様書は クラス 1 つに付き 1 つ作成す る 加えて 図 1 のようなクラス継承の模式図を作成せよ < クラス名 のプログラム仕様書 > 作成者 : 学籍番号 名前 (1) クラスクラス名 : クラス名 説明 : クラスが何を表現しているか

More information

1_cover

1_cover BetweenAS3 Updater Spark Project #APMT 2009.9.11 TAKANAWA Tomoaki ( http://nutsu.com ) http://www.libspark.org/svn/as3/betweenas3/tags/alpha-r3022/ public static function tween(...):iobjecttween { var

More information

Method(C 言語では関数と呼ぶ ) メソッドを使うと 処理を纏めて管理することができる 処理 ( メソッド ) の再実行 ( 再利用 ) が簡単にできる y 元々はC 言語の関数であり 入力値に対する値を 定義するもの 数学では F(x) = 2x + 1 など F(x)=2x+1 入力値 (

Method(C 言語では関数と呼ぶ ) メソッドを使うと 処理を纏めて管理することができる 処理 ( メソッド ) の再実行 ( 再利用 ) が簡単にできる y 元々はC 言語の関数であり 入力値に対する値を 定義するもの 数学では F(x) = 2x + 1 など F(x)=2x+1 入力値 ( Method(C 言語では関数と呼ぶ ) メソッドを使うと 処理を纏めて管理することができる 処理 ( メソッド ) の再実行 ( 再利用 ) が簡単にできる y 元々はC 言語の関数であり 入力値に対する値を 定義するもの 数学では F(x) = 2x + 1 など F(x)=2x+1 入力値 ( 引数 ) x が決まれば F(x) が決まる これを応用して 複雑な処理も 外面的にはひと固まりの処理として扱う

More information

Assignment_.java 課題 : 転置行列 / class Assignment_ public static void main(string[] args) int i,j; int[][] array = 1,,,,,,,,,,,,,1,1,; 行 列行列 i

Assignment_.java 課題 : 転置行列 / class Assignment_ public static void main(string[] args) int i,j; int[][] array = 1,,,,,,,,,,,,,1,1,; 行 列行列 i 1 1 0 1 Assignment_1.java 課題 1: チェッカー / class Assignment_1 public static void main(string[] args) int i,j; チェッカー用の 次元配列 int[][] checker=new int[][]; チェッカーパターンを書き込む for(i=0;i

More information

Microsoft PowerPoint - ●SWIM_ _INET掲載用.pptx

Microsoft PowerPoint - ●SWIM_ _INET掲載用.pptx シーケンスに基づく検索モデルの検索精度について 東京工芸大学工学部コンピュータ応用学科宇田川佳久 (1/3) (2/3) 要員数 情報システム開発のイメージソースコード検索機能 他人が作ったプログラムを保守する必要がある 実務面での応用 1 バグあるいは脆弱なコードを探す ( 品質の高いシステムを開発する ) 2 プログラム理解を支援する ( 第 3 者が書いたコードを保守する ) 要件定義外部設計内部設計

More information

オブジェクト指向プログラミング・同演習 5月21日演習課題

オブジェクト指向プログラミング・同演習 5月21日演習課題 オブジェクト指向プログラミング 同演習 5 月 21 日演習課題 問題 1 配列の例外処理例外が発生する可能性のある処理を try で囲み その後に catch で例外を捕捉します 例外処理の終了処理として finally が行われます これは書かなくて自動的に行われます 提出課題 1 (Kadai052301.java) 以下のプログラムは例外処理をしていない ArrayIndexOutOfBoundsException

More information

2.2 Java C main Java main 2 C 6 C Java 3 C Java ( ) G101Hello.java G101Hello main G101Hello.java /* G101Hello */ class G101Hello { /* main */ public s

2.2 Java C main Java main 2 C 6 C Java 3 C Java ( ) G101Hello.java G101Hello main G101Hello.java /* G101Hello */ class G101Hello { /* main */ public s 2 2013 4 16 2.1............................... 2 1 2.2 Java......................... 2 2 2.3............. 2 2 2.4................................ 2 4 2.5............................ 2 5 2.6............................

More information

cpp1.dvi

cpp1.dvi 2017 c 1 C++ (1) C C++, C++, C 11, 12 13 (1) 14 (2) 11 1 n C++ //, [List 11] 1: #include // C 2: 3: int main(void) { 4: std::cout

More information

Java Java Java Java Java 4 p * *** ***** *** * Unix p a,b,c,d 100,200,250,500 a*b = a*b+c = a*b+c*d = (a+b)*(c+d) = 225

Java Java Java Java Java 4 p * *** ***** *** * Unix p a,b,c,d 100,200,250,500 a*b = a*b+c = a*b+c*d = (a+b)*(c+d) = 225 Java Java Java Java Java 4 p35 4-2 * *** ***** *** * Unix p36 4-3 a,b,c,d 100,200,250,500 a*b = 20000 a*b+c = 20250 a*b+c*d = 145000 (a+b)*(c+d) = 225000 a+b*c+d = 50600 b/a+d/c = 4 p38 4-4 (1) mul = 1

More information

DVIOUT-exer

DVIOUT-exer プログラム理論と言語 : 期末試験用問題集 Part2 (2009) 演習問題 2-0 オブジェクト指向言語, とりわけ Java に関する用語の設問をもうける. 重要な語句については復習をしておくこと. 1 演習問題 2-1( レジメ記載の問題を具体化した問題 ) 下記は, 整数 (int) を要素とする線形リストのプログラムである. class IntCell { private int value

More information

JAVA入門

JAVA入門 JAVA 入門後期 10 情報処理試験例題解説 H14 年度秋問 8 次の Java プログラムの説明及びプログラムを読んで, 設問に答えよ プログラムの説明 ディジタル論理回路シミュレータを作成するためのクラスとテスト用クラスである (1) ゲートを表す抽象クラス Gate のサブクラスとして, NOT ゲートを表すクラス NotGate 及び AND ゲートを表すクラス AndGate を定義する

More information

Prog2_9th

Prog2_9th 2013 年 11 月 21 日 ( 木 ) 実施例外処理 Java 言語では, 作成したプログラムを実行する際に, 記述した処理が想定しない事態によって実行できなくなる場合を例外と呼び, その例外への対処, 即ち例外処理が求められる これまでの教材に登場した例外の中で,IOException はコンパイラがチェックするため, 例外処理を必ず記述しなければコンパイルが出来ないものであるのに対して,ArithmeticException

More information