10/8 Finder,, 1 1. Finder MAC OS X 2. ( ) MAC OS X Java ( ) 3. MAC OS X Java ( ) / 10



Similar documents
r1.dvi

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

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

K227 Java 2

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

2

明解Java入門編

2

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

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

デジタル表現論・第6回

デジタル表現論・第4回

Week 1 理解度確認クイズ解答 解説 問題 1 (4 2 点 =8 点 ) 以下の各問いに答えよ 問題 bit 版の Windows8.1 に Java をインストールする時 必要なパッケージはどれか 但し Java のコンパイルができる環境をインストールするものとする 1. jdk

8 if switch for while do while 2

: : : TSTank 2

Java学習教材

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 updated

新・明解Java入門

Microsoft Word - keisankigairon.ch doc

Java演習(2) -- 簡単なプログラム --

解きながら学ぶJava入門編

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

新・明解Java入門

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

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

スライド 1

PowerPoint プレゼンテーション

ex01.dvi

Java講座

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

コーディング基準.PDF

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

I java A

問題 01 水道料金を節約しよう 問題のポイント問題文で述べられた仕様を理解し その通りに動作するプログラムを記述できるかを問う問題です 変数 入出力 四則演算に加え 条件分岐や繰り返し処理についての知識が必要です 問題の解き方いくつかのアルゴリズムが考えられますが w が 100 以下と小さい値な

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

●70974_100_AC009160_KAPヘ<3099>ーシス自動車約款(11.10).indb

本サンプル問題の著作権は日本商工会議所に帰属します また 本サンプル問題の無断転載 無断営利利用を厳禁します 本サンプル問題の内容や解答等に関するお問 い合わせは 受け付けておりませんので ご了承ください 日商プログラミング検定 STANDARD(Java) サンプル問題 知識科目 第 1 問 (

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

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

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

ALG ppt

Microsoft Word - java a.doc

プログラミング入門1

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

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

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

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

19 3!! (+) (>) (++) (+=) for while 3.1!! (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics;

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

1.ppt

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

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

プログラミングA

PowerPoint プレゼンテーション

ex01.dvi

JavaプログラミングⅠ

JAVA 11.4 PrintWriter 11.5

Microsoft PowerPoint - prog03.ppt

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

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

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

プログラミング基礎I(再)

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

ALG2012-C.ppt

プログラミング入門1

r02.dvi

ohp02.dvi

情報処理Ⅰ

untitled


Microsoft Word - NonGenTree.doc

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

Microsoft PowerPoint - java13bb.ppt

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

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

ohp07.dvi

text_08.dvi

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

2 1 Web Java Android Java 1.2 6) Java Java 7) 6) Java Java (Swing, JavaFX) (JDBC) 7) OS 1.3 Java Java

(2000 )

JavaプログラミングⅠ

Informatics 2010.key

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

Javaセキュアコーディングセミナー東京 第3回 入出力(File, Stream)と例外時の動作 演習解説

2

2

ALG2012-F.ppt

text_11.dvi

JavaプログラミングⅠ

マークアップ言語

Prog1_3rd

10K pdf

プログラミング入門1

JavaプログラミングⅠ

プログラムの基本構成

文字列操作と正規表現

Microsoft Word - NonGenList.doc

55 7 Java C Java TCP/IP TCP/IP TCP TCP_RO.java import java.net.*; import java.io.*; public class TCP_RO { public static void main(string[] a

目 次 オブジェクト指向 1 3 オブジェクト指向 2 9 二分探索 14 二次元配列 16 ソート 18 ArrayList 25 解答 27 2

Transcription:

10/8 2015-10-08 URL : http://webct.kyushu-u.ac.jp, 10/8 1 / 10

10/8 Finder,, 1 1. Finder MAC OS X 2. ( ) MAC OS X Java ( ) 3. MAC OS X Java ( ) 1. 30 2 / 10

10/8 Finder 1 Figure : : Apple.com 2, 3 / 10

10/8 Finder ( ) 1, CS 2 CS : Finder, Finder (4372277867 ) 4 / 10

10/8 Finder, 1 :, CS 5 / 10

10/8 Finder cd. cd CS., CS touch test.txt, CS text.txt. text.txt 2.. 2 6 / 10

10/8 : cd CS ls pwd mv filea fileb mv filea FolderB cp filea fileb cp filea FolderB mkdir FolderA CS filea fileb filea FolderB filea fileb filea FolderB FolderA, Google 7 / 10

10/8 Java Web page quiz1.java quiz2.java CS webct, CS, Java javac quiz1.java return 8 / 10

10/8 java quiz1 return Input positive integer, ( ) 2 : 3 3 : quiz2.java, 4 3 4 9 / 10

10/8 URL : http://webct.kyushu-u.ac.jp, 10/8, 10/8 PM 11:59 10 / 10

10/8 10/22 2015-10-22 URL : http://webct.kyushu-u.ac.jp, 10/22 1 / 16

10/8 10/22 1 I,.. JAVA,, JAVA 2 / 16

10/8 10/22 1 II, TA.. Java JAVA,. 3 / 16

10/8 10/22 1 III. Android. 4 / 16

10/8 10/22 JAVA JAVA,,,, if, for, while ( ) Copy & Paste. 5 / 16

10/8 10/22 Hello World! public class Hello public static void main String[] args System.out.println "Hello World!" ; Hello.java & javac Hello.java java Hello 1 Hello 3. 1 Hello Hello.java 6 / 16

10/8 10/22 Hello World! public class Hello public static void main String[] args System.out.println "Hello World!" ; ( 1) { } 1 { } 2 { } 2 4 tab 1 3 Hello World! "Hello World!", \"Hello World!" 7 / 16

10/8 10/22 3 + 4 = 7 5 * 6 = 30 7 / 8 = 0 7.0 / 8.0 = 0.875 public class keisan public static void main String[] args System.out.println "3 + 4 = "+ (3+4) ; System.out.println "5 * 6 = "+ (5*6) ; System.out.println "7 / 8 = "+ (7/8) ; System.out.println "7.0 / 8.0 = "+ (7.0/8.0) ; 1 &. 8 / 16

10/8 10/22 System.out.println(" "); System.out.print(" "); : println print? public class keisan public static void main String[] args System.out.print "3 + 4 = "+ (3+4) ; System.out.print "5 * 6 = "+ (5*6) ; System.out.print "7 / 8 = "+ (7/8) ; System.out.print "7.0 / 8.0 = "+ (7.0/8.0) ; 3 + 4 = 75 + 6 = 307 / 8 = 07.0 / 8.0 = 0.875 9 / 16

10/8 10/22???.java public class??? public static void main String[] args ( ) System.out.println ( ), System.out.println(" "); System.out.print(" "); A B, + /! 10 / 16

10/8 10/22 :,, ( x 4 int x; x = 4; int x = 4; :, x 3 int x = 4; x = 3; 11 / 16

10/8 10/22 ( x 4.0 double x; x = 4.0; double x = 4.0; :, x 3.5 double x = 4.0; x = 3.5; ( x c char x; x = c ; char x = c ; 12 / 16

10/8 10/22 2 :, x, y. sample.java. int x = 10 x = x 1 // (1) x x = x*x // (2) x double y = 5.5 y = x*y // (3) y 13 / 16

10/8 10/22 ( ) ( import java.util.scanner // public class ( ) Scanner input = new Scanner System.in int N = input.nextint, N ( import java.util.scanner // public class ( ) Scanner input = new Scanner System.in ; double x = input.nextdouble ;, x 14 / 16

10/8 10/22 3 : keisan3.java. x y 1. x = y = x + y = x * y = x / y = 15 / 16

10/8 10/22 URL : http://webct.kyushu-u.ac.jp, 10/22, 10/22 PM 11:59 16 / 16

10/22 10/29 2015-10-29 URL : http://webct.kyushu-u.ac.jp, 10/29 1 / 21

10/22 10/29 10/22 10/29 10/22 2., or.,, 2 / 21

10/22 10/29 1 :, (double quotation). 3 / 21

10/22 10/29 2 :, System.out.println 4 / 21

10/22 10/29 JAVA 2 JAVA,,,, if, for, while ( ) Copy & Paste. 5 / 21

10/22 10/29 (int) 2. 1bit 0 1 nbit ( 1) s n 1, s, a 1,..., a n 1 {0, 1}, a i 2 i i=1 32bit, 2 31 2 31 1 64bit, 2 63 2 63 1 6 / 21

10/22 10/29 (double), 64bit. s e e e e m m m m m s, e(11 ), m(52 ) x = ( 1) s 2 e 1023 ( 1 + 52 i=1. x = 0.1 d i 2 i ) 7 / 21

10/22 10/29 : int x = 1; x = x + 1.0; x int 1.0 double ( ) I int x = 1; x = x + (int)1.0; // x = 2 double int = 1.0 1 int x = 1; x = x + (int)1.75; // 2.75 2 8 / 21

10/22 10/29 ( ) II x = 7/8; // x 0 x = (double)7/(double)8; // x 0.875 x = 7.0/8; // x 0.875 x = 7.0/8.0; // x 0.875 : double, double., double y = 1.0; // y = 1; y = 2.0 * Math.sin(Math.PI/2.0); // y = 2*Math.sin(Math.PI/2); 9 / 21

10/22 10/29 if if : if ( ) { true ; } true, false 1 : p... int p;... if (p >= 50) { System.out.println("It will rain today."); } 10 / 21

10/22 10/29 if : if ( ) { true ; }else{ false ; } 2 : p... int p;... if (p >= 50) { System.out.println("Need an umbrella."); }else{ System.out.println("Not need an umbrella."); } 11 / 21

10/22 10/29 if : if ( A) { A true ; }else if ( B){ B true ; }else{ A B false ; } 3 : p... if (p >= 0 && p<=20) { System.out.println("Sunny!"); }else if(p > 20 && p <=50 ){ System.out.println("Cloudy."); }else{ System.out.println("Rainy."); } 12 / 21

10/22 10/29 if : Tabelle: if Java p == 50 p = 50 p 50 true, false p!= 50 p 50 p 50 true, false p >= 50 p 50 p 50 true, false p <= 50 p 50 p 50 true, false p > 50 p > 50 p 50 true, false p < 50 p < 50 p 50 true, false p >= 0 && p <= 20, 0 p p 20 p >= 40 p <= 20, p 40 p 20 13 / 21

10/22 10/29 10/8 if(n % 3 == 0 && N % 5 == 0){ System.out.println("FizzBuzz"); }else if(n % 3 == 0){ System.out.println("Fizz"); }else if(n % 5 == 0){ System.out.println("Buzz"); }else{ System.out.println(N); } N, FizzBuzz : N % 3 N 3 14 / 21

10/22 10/29 https://docs.oracle.com/javase/8/ docs/api/java/lang/math.html) I : double x = Math.random(); // 0 1 int y = (int) (9*Math.random()); // 0 8 double z = 2*Math.random()-1.0; // -1 1 double x = Math.abs(-3.0);, double x = Math.sqrt(2.0); double y = Math.cbrt(2.0); 15 / 21

10/22 10/29 https://docs.oracle.com/javase/8/ docs/api/java/lang/math.html) II, log e double x = Math.pow(1.5, 6);// 1.5 6 double y = Math.log(1.3); sin(x), cos(x), tan(x) double x = Math.sin(2.0); double y = Math.cos(Math.PI/2.0); double z = Math.tan(-Math.PI); arcsin(x), arccos(x), arctan(x) double x = Math.asin(0.5); double y = Math.acos(0.5); double z = Math.atan(-10); 16 / 21

10/22 10/29 https://docs.oracle.com/javase/8/ docs/api/java/lang/math.html) III π, e double x = Math.PI; double y = Math.E;, double x = Math.ceil(1.5); double y = Math.floor(1.5); 17 / 21

10/22 10/29 1 : double d = Math.random();,. Omikuji.java. d < 0.1, Great blessing 0.1 d < 0.3, Small blessing 0.3 d < 0.5, Blessing 0.5 d < 0.7, Curse 0.7 d < 0.9, Small curse 0.9 d < 1.0, Great curse d 18 / 21

10/22 10/29 2 : π Java π. pi.java. (Machin ) π ( ) ( ) 1 1 = 4 arctan arctan, 4 5 239 (Euler ) π ( ) ( ) 1 3 = 5 arctan + 2 arctan, 4 7 79 (Stormer ) π ( ) ( ) ( ) 1 1 1 = 6 arctan + 2 arctan + arctan. 4 8 57 239 double p1 = 4*Math.atan(1.0/5.0)-Math.atan(1.0/239.0); // Machin... System.out.println("Machin = "+ (p1*4));... System.out.println("PI = "+Math.PI); 19 / 21

10/22 10/29 3 : N(, 2500 ),. leap.java. (Wikipedia ): N 4, (N 4 ) N 100, (N 4 100 ) N 400, (N 4 100 ) N 400, Input a positive integer :101 Not leap Input a positive integer :204 Leap Input a positive integer :100 Not leap Input a positive integer :1200 Leap 20 / 21

10/22 10/29 URL : http://webct.kyushu-u.ac.jp, 10/29, 10/29 PM 11:59 21 / 21

10/29 11/5 2015-11-05 URL : http://webct.kyushu-u.ac.jp, 11/5 1 / 13

10/29 11/5 10/29.,,. Omikuji.java leap.java if. Omikuji.java if(d < 0.1){ System.out.println("Great blessing"); }else if(d < 0.3){ System.out.println("Small blessing");...( )... }else if(d < 1.0){ System.out.println("Great curse"); } System.out.println("d = "+d); } 2 / 13

10/29 11/5 JAVA 3 JAVA,,,, if, for, while ( ) Copy & Paste. 3 / 13

10/29 11/5 for ( ) π 4 = ( 1) n 2n + 1 n=0,, π/4 : p N = N n=0 ( 1) n 2n + 1 π 4 (N ), N = 0 N = 6 4 / 13

10/29 11/5 double p = 1.0; // N=0 System.out.println("p = "+p); p = p - 1.0/3.0; // N = 1 System.out.println("p = "+p); p = p + 1.0/5.0; // N = 2 System.out.println("p = "+p); p = p - 1.0/7.0; // N = 3 System.out.println("p = "+p); p = p + 1.0/9.0; // N = 4 System.out.println("p = "+p); p = p - 1.0/11.0; // N = 5 System.out.println("p = "+p); p = p + 1.0/13.0; // N = 6 System.out.println("p = "+p); p ( 1) n /(2n + 1) N = 10 5 / 13

10/29 11/5 for... double p = 1.0; // N = 0 int N = 10; // N=10 for(int n=1; n < N+1; n++){ if(n % 2 == 0){ p = p + 1.0/(2*n+1); }else{ p = p - 1.0/(2*n+1); } System.out.println("p = "+p); } 6 / 13

10/29 11/5 for for( ; ; ){ ( ); } 1 : 0 99 for(int i=0; i<100; i++){ System.out.println("i = "+i); } 1 i=0 i<100 i=0 i=i+1 i=1 2 i=1 i<100 i=1 i=i+1 i=2 3 4 i=100 i<100 7 / 13

10/29 11/5 for : for( ; ; ){ ( ); } 2 : 10 k=1 k int sum = 0; for(int k=1; k<=10; k++){ sum = sum + k; } 1 k=1 k<=10 sum = 1 k=k+1 k=2 2 k=2 k<=10 sum = 3 k=k+1 k=3 3 4 k=11 k<=10 8 / 13

10/29 11/5 for 3 : DrawGraph1.java public class DrawGraph1{ public static void main(string[] args){ for(int i=0; i<10; i++){ System.out.print(i +":"); for(int j=0; j<i; j++){ System.out.print("*"); } System.out.println(""); } } } for for j < i for, i i, j 9 / 13

10/29 11/5 1 : ( ) 1 N, N!. factorial.java. N! := N (N 1) 3 2 1. 2 : 2 N, N. divisor.java. Input a positive integer :10 1 2 5 10 Input a positive integer :5 1 5 10 / 13

10/29 11/5 3 : ( for I). Kuku.java. 3 1*1=1, 1*2=2, 1*3=3, 1*4=4, 1*5=5, 1*6=6, 1*7=7, 1*8=8, 1*9=9, 2*1=2, 2*2=4, 2*3=6, 2*4=8, 2*5=10, 2*6=12, 2*7=14, 2*8=16, 2*9=18, 3*1=3, 3*2=6, 3*3=9, 3*4=12, 3*5=15, 3*6=18, 3*7=21, 3*8=24, 3*9=27, 4*1=4, 4*2=8, 4*3=12, 4*4=16, 4*5=20, 4*6=24, 4*7=28, 4*8=32, 4*9=36, 5*1=5, 5*2=10, 5*3=15, 5*4=20, 5*5=25, 5*6=30, 5*7=35, 5*8=40, 5*9=45, 6*1=6, 6*2=12, 6*3=18, 6*4=24, 6*5=30, 6*6=36, 6*7=42, 6*8=48, 6*9=54, 7*1=7, 7*2=14, 7*3=21, 7*4=28, 7*5=35, 7*6=42, 7*7=49, 7*8=56, 7*9=63, 8*1=8, 8*2=16, 8*3=24, 8*4=32, 8*5=40, 8*6=48, 8*7=56, 8*8=64, 8*9=72, 9*1=9, 9*2=18, 9*3=27, 9*4=36, 9*5=45, 9*6=54, 9*7=63, 9*8=72, 9*9=81, 11 / 13

10/29 11/5 3 :??? for(int i=0;???; i++){ for(int j=0;???; j++){???; }???; }, System.out.println System.out.print 12 / 13

10/29 11/5 URL : http://webct.kyushu-u.ac.jp, 11/5, 11/5 PM 11:59 13 / 13

11/5 11/12 2015-11-12 URL : http://webct.kyushu-u.ac.jp, 11/12 1 / 11

11/5 11/12. public class divisor { public static void main (String[] args){ int n = 1; for(int a = 1; a<=n; n++){ if(n%a==0){ System.out.println(a); } } } } 2 / 11

11/5 11/12 Control c for 3 / 11

11/5 11/12 JAVA 4 JAVA,,,, if, for, while ( ) Copy & Paste. 4 / 11

11/5 11/12 while while : while( ){ ( ); } 1 : i=0,..., 99 int i = 0; while(i < 100){ System.out.println("i = "+i); i = i + 1; } 1 i = 0 while i = 0 i=1 2 i = 1 while i = 1 i=2 3 4 i = 100 while 5 / 11

11/5 11/12 2 : x = 100 1.08 200 double x = 100.0; int c = 0; while(x <= 200){ x = x * 1.08; c = c + 1; } System.out.println("c = "+c); 1 x = 100.0 while x = 108.0, c = 1 2 x = 108.0 while x = 116.64, c = 2 3 4 x = 215.89... while while 5 c = 10 6 / 11

11/5 11/12 while : while( ){ ( ); } do while : do{ ( ); }while( );, while(true){... } break,. ctrl-c. 7 / 11

11/5 11/12 for, while for while. for while., for, while 8 / 11

11/5 11/12 1 : 0,, 0. inputintsum.java. import java.util.scanner;... while( ){ scanner input = new Scanner(System.in); System.out.print("Input an integer :"); N = input.nextint(); ( ); },. N int while. do-while? 9 / 11

11/5 11/12 1 Input a positive integer :10 Input a positive integer :20 Input a positive integer :1 Input a positive integer :0 sum = 31 Input a positive integer :13 Input a positive integer :-2 Input a positive integer :4 Input a positive integer :0 sum = 15 10 / 11

11/5 11/12 2 : ( ) γ γ N (, N ): γ N := N k=1 1 k log(n). while, γ N γ N 1 ϵ N.,, ϵ = 10 6. ϵ = 10 6 double eps = 1.0e-6;. eulersconst.java., lim N γ N = 0.5772156649 11 / 11

11/5 11/12 URL : http://webct.kyushu-u.ac.jp, 11/12, 11/12 PM 11:59 12 / 11