note.dvi

Size: px
Start display at page:

Download "note.dvi"

Transcription

1 25 3 PASCAL 3.1 PASCAL, PASCAL, PASCAL,.,, PASCAL PASCAL,.,.,.. test.p,.p..,,. 3.3 PASCAL. 1. (Mule ),. 2.,. 3.., Mule, hello.p,,. % pc hello.p -o hello -o hello, hello., -o hello, a.out. hello %./hello.,./ 1. Exercise test.p 1 UNIX,.

2 26 % pc test.p -o test,, % test, PASCAL PASCAL SPARCompiler SUN MicroSystems., ANSI,., PASCAL, SPARCompiler.,,,. 3.4 PASCAL PASCAL Program PASCAL,,,.,,.,,, ;, end., C, ;, Bachus-Naur formula PASCAL, Bachus-Naur formula (BNF). BNF, ::= { } BNF, PASCAL. {}. BNF Id: P1.tex,v /04/21 02:09:32 naito Exp

3 27 ::=. ::= program ( {, } ) ; ::= ::= { } ::= ::= PASCAL PASCAL,,,,,,.,. PASCAL, 2., PASCAL,,.,.,,,, ,.,., {, }., {}, (* *). 3., ,,,,,. PASCAL,., ,, PASCAL. PASCAL. ::= + - * / = < > [ ]., := ; ; ( ) <> <= >=.. ^ SPARCompiler,. ~ &! # % 2 SPARCompiler, default.,. 3 SPARCompiler, /*, */, ".,. Id: P1.tex,v /04/21 02:09:32 naito Exp

4 28, SPRACompiler. ::= + - * / = < > [ ]., := ; ; ( ) <> <= >=.. ^ ~ &! # % ,,. and array case const div do downto else file for forward function goto if in label main mod nil not of or packed procedure program record repeat set then to type until var while with, SPARCompiler,. define extern external module otherwise private public static univ PASCAL, $, _,, system,. PASCAL. abs arctan boolean char chr cos dispose eof eoln exp false get input integer ln maxint new odd ord output page pred put read readln real reset rewrite round sin sqr sqrt succ text true trunc write writeln, SPARCompiler, FALSE TRUE addr alfa argc argv arshft asl asr assert bell card clock close date discard double exit expo firstof flush getenv getfile halt in_range index integer16 integer32 intset land lastof length linelimit lnot longreal lor lshft lsl lsr max maxchar message min minchar minint next null open pack random remove return rshft seed shortreal single sizeof stlimit string substr sysclock tab time trim univ_ptr unpack varying wallclock xor PASCAL 4.,. ::= { } ::= ::=.. E E ::= ::= ::= + -, E E+8 4,. Id: P1.tex,v /04/21 02:09:32 naito Exp

5 29, 87.35E+8, (+8)., SPARCompiler, 2 36., ::= { } BASE ::= BASE ::= BASE # ::= BASE, A Z. [0, maxint] ,. ::=, ,. ::= ::= ::= = PASCAL,.,,..,,.,. Example x 15 sin(x+y) x*y x+y -x x = 1.5,,. Id: P1.tex,v /04/21 02:09:32 naito Exp

6 , PASCAL,., ;. Example x := y + z,., end. Example a := b ; c := d ; end Example { Program 1 Hello World.. } program Hello_World (output) ; writeln( Hello World. ),. (,,.) program Hello_World (output) ;., Hello_World.,,, output.,, input.. PASCAL, end..,.. Id: P2.tex,v /04/21 02:10:17 naito Exp

7 31 writeln( Hello World. ) writeln,,, 5.,., ;. end, ;.,,. C,. PASCAL. Exercise Program 1,. ( ) ( ) ( ), 3.6 Section 3.4.1, PASCAL.,. BNF,. ::=. ::= program ( {, } ) ; ::= ::= { } ::= ::=,,,,, , PASCAL,.,, input output,. readln, writeln, input, output ,., 6. 5.,. 6,,. Id: P3.tex,v /04/21 02:12:24 naito Exp

8 32, PASCAL goto, PASCAL, goto,.. ::= label {, } ; ::=, [0, 9999].,,,., ::= const = ; { = ; }.,. ::= ::=,,,,,. Example const a = 32 ; b = 1.0 ; c = -2.0 ; d = a ; e = -b ; f = ; PASCAL,,. PASCAL.. ::= type = ; { = ; } ::=., Example, PASCAL.,,. ::= var {, } : ; { {, } : ; } Example Id: P3.tex,v /04/21 02:12:24 naito Exp

9 33 var a, b : integer ; c, d : real ; e : Boolean ; f : char ;,,.,,.,,,. 3.7,,. PASCAL,,,,.,,,,,.,,,.,,,,.,, PASCAL,., PASCAL,.,, var a,b : integer ; a := 1 ; b := 1 end ;., SPARCompiler,. var a,b : integer := 1 ;,.,, a, b,, PASCAL,. Id: P3.tex,v /04/21 02:12:24 naito Exp

10 34 ::= ::= ::= ::= ::= ::= ( {, } ) ::= ,.,,. Example type color = (white, red, blue, yellow, green, black) ; day = (mon, tue, wed, thr, fri, sat, sun) ; Example type workday = (mon, tue, wed, thr, fri, sat, sun) ; free = (sat, sun) ;, sat,., 0.,.,,. succ. pred. SPARCompiler, firstof, PASCAL,,..... true false ,,..,.. Id: P3.tex,v /04/21 02:12:24 naito Exp

11 35 Example var a : ; b : ;. Example type days = (mon,tue,wed,thr,fri,sat,sun) ; workd = mon..fri ; letter = a.. z ;, days., integer,,., real,, Boolean, type Boolean = (false, true) ;., false true,, false < true char,,..,,...., 7.,, 0.. 7,, ASCII. Id: P3.tex,v /04/21 02:12:24 naito Exp

12 36 0 9,. A Z,,. a z,,.,.. ord,. chr chr(i) i..,, pred, succ, pred(c) = chr(ord(c)-1) succ(c) = chr(ord(c)+1) , T 1 T 2. (a) T 1 T 2. (b) T 1 T 2, T 2 T 1, T 1 T 2. (c) T 1 T 2,,. (d) T 1 T ,, ,. SPAR- Compiler, ASCII,. SPARCompiler, minchar, maxchar, bell, tab. minchar 0, maxchar 255, bell 7, tab 9. Id: P3.tex,v /04/21 02:12:24 naito Exp

13 ,.,,,, 2 n. SPARCompiler,., -xl., SPARCompiler, integer16, integer32,., maxint, minint maxint PASCAL., integer,., PASCAL, C,, , Section ,.,,, 2 n. SPARCompiler, real., -xl., SPARCompiler, single, shortreal, double, longreal,,,.,.,. (0 ).< > 10^< >, 0,., , Section 1.4.,,., , ,. Id: P3.tex,v /04/21 02:12:24 naito Exp

14 38,.,, ,,, PASCAL, x = x PASCAL,,,.,.,,,......,, , PASCAL., Jensen-Wirth., SPARCompiler., SPARCompiler PASCAL,,,,,,,.,,. Id: P3.tex,v /04/21 02:12:24 naito Exp

15 :=.,,.,,.. ::= := := , T 2, T 1. (a) T 1 T 2,. (b) T 1 T 2. (c) T 1 T 2, T 2 T 1. (d) T 1 T 2, T 2, T 1. (e) T 1 T 2. T 2 T 1, T 1 T 2., not,,. ::= not ::= * / div mod and. *,, /, div mod and, / div /, x/y, y 0,, y 0, x/y, x y. x div y, y 0,,. Id: P3.tex,v /04/21 02:12:24 naito Exp

16 40 abs(i) - abs(j) < abs((i div j) * j) abs(i), abs,,., abs(i) < abs(j) i div j 0. i mod j, j., i mod j. i mod j = j - (k*j), k. 0 i mod j < j, i 0, j > 0, (i div j) * i + i mod j =i ::= + - or. +,, -, or, +, -,, -, ,,. ::= = <> < > <= >= in. in T T =, <>,,, T <, >, <=, >=,, T <>, <=, >=,,,., <=, >=,. Id: P3.tex,v /04/21 02:12:24 naito Exp

17 41, p, q, p=q., p<=q, p q., false < true. <>.,, ,,,,.,,,,,,.,,,., PASCAL.,. maxint,. [-maxint, maxint],.,,., trunc(x) x.. trunc(x), x, 0 x - trunc(x) < 1,, 1 < x + trunc(x) 0.,., trunc(3.5) =3,trunc(-3.5) = 3. round(x) x.. round(x), x, round(x) trunc(x+0.5)., round(x) trunc(x-0.5).,., round(3.5) =4., round(-3.5).,, , ,,.,,,,,,.,,.,.,. Id: P3.tex,v /04/21 02:12:24 naito Exp

18 42 ::= nil ::= ( ) not ::= [ ] ::= {, } ::=.. ::= ::= ::=,,. [], [x..y], x y. Example 3.9.1, x 15 (x+y+z) not p [red,black,green] [1..10]., x*y p or q (x<=y) and (y<z). x+y -x i*j-1. x = 1.5 p<=q (i<j)=(j<k) c in h., not,., (),.,. Example a := 1 ; b := 2 ; c := 3 ; d := 4 ;, (a > b) and (c < d), a > b, false., and, false. Id: P3.tex,v /04/21 02:12:24 naito Exp

19 43 PASCAL,.,,,.,. C,,,.. PASCAL., C., C, a > b && c < d, PASCAL, and >, <, SPARCompiler, 8. ~ bitwise not & bitwise and bitwise or! bitwise or, bitwise not, bitwise and, bitwise or SPARCompiler, 9. asl asr lsl lsr ,.,,. 1, 1.,, 1, 2, 1, 2.,,,,.,. Example 3.9.3, , SPARCompiler. Id: P3.tex,v /04/21 02:12:24 naito Exp

20 , 1. Example 3.9.4, ,,. Example 3.9.5, Example 3.9.6, ,., writeln. Example ,. program print_example (output) ; var a : char ; b,c : integer ; x : real ; a := a ; b := 1 ; c := 2 ; x := 1.0 ; writeln( a =,a) ; writeln( b =,b, c =,c) ; writeln( b div c =,b div c) ; writeln( b / c =,b/c) ; writeln( x =,x) writeln, SPARCompiler writeln.. Id: P3.tex,v /04/21 02:12:24 naito Exp

21 45 Exercise Exercise integer 1. Exercise Exercise , writeln.,,,. Exercise AND, OR, NOT XOR ::= { : } ,,,,. ::= goto ::=., goto goto. goto ::= goto, goto PASCAL,, ,. ::= with ::= { ; },,., goto. Id: P4.tex,v /04/21 02:13:09 naito Exp

22 ,. ::= end Example z := x ; x := y end ::= if case if if,. if ::= if then { else } else ::= else, if true, if. false, if, else. else if else., if e1 then if e2 then s1 else s2 if e1 then if e2 then s2 else s2 end. Example if. if x <> 1.5 then z := x + y else z := 1.5 ; if x <> 1.5 then z:= x + y if x <> 1.5 then if y <> 2.0 then z:= x + y else z := y else z := x Id: P4.tex,v /04/21 02:13:09 naito Exp

23 case case,,. case ::= case of { ; } end ::= : ::= ::= {, } ::= Example case. case x of 1: y := x ; 2: z := x ; 3,4: w := x end, case, ,,. ::= repeat while for repeat repeat ::= repeat until repeat, true.,. Example , program sum ; var i,j : integer ; i := 0 ; j := 1 ; repeat i := i + j ; j := j+1 ; until j = 11 ; Id: P4.tex,v /04/21 02:13:09 naito Exp

24 while while ::= while do while while b do body if b then repeat body until not(b) end.,, true,, false.,. Example , program sum ; var i,j : integer ; i := 0 ; j := 1 ; while j <= 10 do i := i + j ; j := j+1 ; end for for,. for ::= for := { to downto } do ::= ::= ::= ::= for,. for..,. for,., for,., goto. for S V,. S, V. S for, V S. Id: P4.tex,v /04/21 02:13:09 naito Exp

25 49 S. S read readln., for v := e1 to e2 do body, v e1, e2, succ body.,,. t1 := e1 ; t2 := e2 ; if t1 <= t2 then v := t1 ; repeat body ; v := succ(v) ; until v > t2 end ;, for v := e1 downto e2 do body, v e1, e2, pred body. Example , program sum ; var i,j : integer ; i := 0 ; for j:=1 to 10 do i := i + j ; Example , program sum ; var i,j : integer ; i := 0 ; for j:=10 downto 1 do i := i + j ;, for, 1, while, repeat with with,. Id: P4.tex,v /04/21 02:13:09 naito Exp

26 , , readln. readln(v),. Example ,. var n : integer ; readln(n) ; writeln(n) random SPARCompiler real.,. Example var n : integer ; r, s : real ; n := seed(wallclock) ; r := random(n) ; s := random(n) ; (SPARCompiler seed,,., random n,., 0 1. Exercise repeat, while, for, 2 N. Exercise , C =(5/9)( F 32).,.,,,,. Exercise integer,. Exercise , 0.5. Exercise , 1+ɛ =1. ɛ. Id: P4.tex,v /04/21 02:13:09 naito Exp

27 51 Exercise for for v := e1 downto e2 do body repeat. 3.12,,,,. ::= ::= ::= { packed } ::= packed,.,, (array),.. ::= array [ {, } ] of ::= ::= Example , integer 0 9 digit. var digit : array [0..9] of integer ;, digit[0] digit[1] digit[2] digit[3] digit[4] digit[5] digit[6] digit[7] digit[8] digit[9],. array [Boolean] of color, color,.,..,.,,.,. 10 SPARCompiler, packed. Id: P5.tex,v /04/21 02:14:33 naito Exp

28 52 Example array [Boolean] of array [1..10] of array [size] of real array [Boolean] of array [1..10,size] of real array [Boolean,1..10] of array [size] of real array [Boolean,1..10,size] of real Example packed array [1..10,1..8] of Boolean ; packed array [1..10] of packed array [1..8] of Boolean ; Example var str : array [0..1][0..9] of integer ; str[i], 10. str[0] [0] str[0] [1] str[0] [2] str[0] [3] str[0] [4] str[0] [5] str[0] [6] str[0] [7] str[1] [0] str[1] [1] str[1] [2] str[1] [3] str[1] [4] str[1] [5] str[1] [6] str[1] [7] str[0] [8] str[0] [9] str[1] [8] str[1] [9]. m, n, k = ord(n) ord(m)+1,, k., v =(v 1,,v k ), v v, v[i] v ord(i) ord(m)+1.,. ::= ::= [ {, } ] ::= ::=,,.,, , real,. program sum_of_vector ; var a,b,c : array[1..3] of real ; i : integer ; a[1] := 1.0 ; a[2] := 1.0 ; a[3] := 2.0 ; b[1] := 2.0 ; b[2] := 0.0 ; b[3] := 3.0 ; for i:=1 to 3 do c[i] := a[i] + b[i] ; Id: P5.tex,v /04/21 02:14:33 naito Exp

29 ,. 1, 1..,,, ,,. program output_of_string (output) ; var s : packed array [1..30] of char ; i : integer ; for i := 1 to 30 do s[i] := chr(ord( A ) + (i-1)) ; writeln(s) ;, 30, SPARCompiler., SPARCompiler,. alfa string varying 10 80, varying[u], u. u , writeln,. var name1 : packed array [1..25] of char ; name2 : packed array [ ] of char ; name3 : alfa ; name4: string ; name5 : varying [25] of char ; name6 : varying [25] of char ; name1 := a ; name2 := a ; name3 := a ; name4:= a ; name5 := a ; name6 := a ; writeln(name1, and, name2) ; writeln(name3, and, name4) ; writeln(name4, and, name6) Id: P5.tex,v /04/21 02:14:33 naito Exp

30 SPRACompiler,,. var int : array [1..10] of integer = [maxint,1,-375,5,20] ; ch : packed array [1..10] of char = ABCDEF ; int2 : array [1..*] of integer = [maxint,1,-375,5,20] ; ch2 : packed array [1..*] of char = ABCDEF ;, *,,. var int : array [1..100] of integer = [50 of 1,50 of 2] ;, 50 1, var int : array [1..100] of integer = [* of 1] ; int2 : array [1..10, 1..10] of integer = [[* of 1], [3 of 8], [10 of 88],] ;, 1, 8, 88., SPARCompiler,,,., ,.,. ::= set of ::=,. set of char ; set of (club, diamond, heart, spade) ; S, T., S, T,, T S. T, A : set of 1..5 ; B : set of 2..9 ;, A and B. Id: P5.tex,v /04/21 02:14:33 naito Exp

31 program set_operation ; type days = (mon,tue,wed,thr,fri,sat,sun) ; week = set of days ; var wk,work,free : week ; d : days ; work := [] ; free := [] ; wk := [mon..sun] ; d := sat ; free := [d] + free + [sun], days, week., week wk, work, free,, free sat sun ,., T : set of T0., T0 N(T0), T, N(T0).,, SPARCompiler,,,, (field). ::= record end ::= { { ; } }{ ; } ::= { ; } ::= : ::= case of { ; } ::= { : } ::= ::= : ( ) ::= ::= {, } ::=,,.. Id: P5.tex,v /04/21 02:14:33 naito Exp

32 56 Example ,. record year : ; month : ; day : end,, year, month, day, integer. m, m., V i i. (V 1,,V m ),.,. Example type month_type = ; days_type = record year : ; case days : month_type of 1,3,5,7,8,10,12 : (days_1 : 1..31) ; 4,6,9,11 : (days_2 : 1..30) ; 2 : (days_3 : 1..28) end, k X k (k, X k ). Example record x, y : real ; area : real ; case shape of rectangle : (side1, side2 : real ; skew : angle) ; circle : (diamiter : real) end,., x, x.side1, rectangle. rectangle, diamiter.,.. ::=. ::= ::= ::=,,.,,. Id: P5.tex,v /04/21 02:14:33 naito Exp

33 57 a : record a : real ; b : real ; end ; b : integer ; Example ,,. program record_test ; type b_year = 1..4; m_year = (m1,m2) ; d_year = (d1,d2,d3) ; b_or_m_or_d = (bachler,master,doctor) ; person = record name : record first, family : string ; end ; id : string ; case kind : b_or_m_or_d of bachler : (gakunen_b : b_year) ; master : (gakunen_m : m_year ; boss_m : string) ; doctor : (gakunen_d : d_year ; boss_d : string) end ; var p : array [1..100] of person ; p[1].name.first := Masashi ; p[1].name.family := Kubo ; p[1].id := ; p[1].kind := doctor ; p[1].gakunen_d := d3 ; p[1].boss_d := Prof. Ihara,,. record case digit : integer of 1 : (S1 : array[1..1] of char) ; 10 : (S2 : array[1..2] of char) ; 100 : (S3 : array[1..3] of char) end, ,,., with with. Id: P5.tex,v /04/21 02:14:33 naito Exp

34 58 with ::= with {, } do,,,. Example Example with p[1],name do first := Masashi ; family := Kubo ; id := ; kind := doctor ; gakunen_d := d3 ; boss_d := Prof. Ihara end with, ,,,,. ::= file of,... Example file of real file of vector, text type text = file of char ; , nil,.,. nil. ::= ::= ^ ::= Id: P5.tex,v /04/21 02:14:33 naito Exp

35 ,. ::= ^ ::= ,..,. ::= ^ ::= ,,,. program a_test (output) ; type ax = array [1..10] of integer ; bx = record a : integer ; b : real ; end ; var a0,a1 : ax ; b0,b1 : bx ; i : integer ; for i:=1 to 10 do a0[i] := i ; end; b0.a := 100 ; b0.b := ; a1 := a0 ; b1 := b Exercise integer,., n, n = t k 3 k, t k = 1, 0, 1,, 1 n, 0 z, 1 p., 5=9 3 1, pnn. Exercise Id: P5.tex,v /04/21 02:14:33 naito Exp

36 60 Exercise A = {1, 2, 3}, B = {2, 3, 4} A B, A B, A B, B A, (A B) (B A). Exercise ,,,. 3.13,,, ,,.,,. ::= ; ; ; ::= procedure ( { { ; }} ) ::= procedure ::= ::= ::= { } ::= var ::= {, } : ::= ::=,.,., forward. forward,, ,,,,,.,.,.,,..,.,., SPARCompiler static,,., Id: P6.tex,v /04/20 12:28:08 naito Exp

37 61,., ,.,. ::= ::= ( {, } ) ::=, read, readln, write, writeln,.,, var,,, ,.,. (call by value) ,.,.,. (call by address) ,., ,., ,,, ,,.,,.,,. Id: P6.tex,v /04/20 12:28:08 naito Exp

38 62 ::= ; ; ; ::= function ( { { ; }} ) ::= function ::= : ::= ::=,,.,.,. ::= Example ,, integer. program print_max (output) ; var x,y : integer ; procedure print_max(x,y : integer) ; var z : integer ; if (x < y) then writeln(y) else writeln(x) ; end ; x := 1 ; y := 2 ; print_max(x,y) Example , integer. Id: P6.tex,v /04/20 12:28:08 naito Exp

39 63 program print_sum (output) ; var x,y : integer ; function return_max(x,y : integer) : integer ; return_max := x + y ; end ; x := 1 ; y := 2 ; writeln(return_max(x,y)) Example ,,,, 11. program vector (output) ; type vector = array [1..2] of real ; var x,y : vector ; r : real ; function get_norm_and_normal (a : vector ; var b : vector) : real ; b[1] := a[2] ; b[2] := (-1)*a[1] ; get_norm_and_normal := sqrt(a[1]*a[1] + a[2]*a[2]) ; end ; x[1] := 1.0 ; x[2] := 0.0 ; r := get_norm_and_normal(x,y) ; writeln( length of (,a[1],,,a[2], ) =,r) ; writeln( normal of (,a[1],,,a[2], ) = (,b[1],,,b[2], ) ) ;,,. Example ,, f(x)+g(y/2). 11. Id: P6.tex,v /04/20 12:28:08 naito Exp

40 64 program sum_of_function_values (output) ; var x,y : real ; function sin_ft(a : real) : real ; sin_ft := sin(a) ; end ; function cos_ft(a : real) : real ; cos_ft := cos(a) ; end ; procedure ch(var a : real) ; a := a/2.0 ; end; function sum_of_function_values ( a,b : real; procedure ch (var a : real) ; function f(a : real) : real ; function g(a : real) : real ) : real ; ch(b) ; sum_of_function_values := (f(a) + g(b)) ; end ; x := 0.0 ; y := 1.0 ; writeln(x,y,sum_of_function_values(x,y,ch,sin_ft,cos_ft)) ; Example ,, forward. Id: P6.tex,v /04/20 12:28:08 naito Exp

41 65 program sum_of_function_values (output) ; var x,y : real ; procedure ch(var a : real) ; forward ; function sin_ft(a : real) : real ; sin_ft := sin(a) ; end ; function cos_ft(a : real) : real ; cos_ft := cos(a) ; end ; function sum_of_function_values ( a,b : real; function f(a : real) : real ; function g(a : real) : real ) : real ; ch(b) ; sum_of_function_values := (f(a) + g(b)) ; end ; procedure ch ; a := a/2.0 ; end; x := 0.0 ; y := 1.0 ; writeln(x,y,sum_of_function_values(x,y,sin_ft,cos_ft)) ; 3.14 section,,. (recursive function call).,.,,.,,,.,. Example , a n+1 = a n +2,a 1 =1 a n. function recursive_function(n : integer) : integer ; if (n = 1) then recursive_function := 1 else recursive_function := recursive_function(n-1) + 2 ; end ; Id: P6.tex,v /04/20 12:28:08 naito Exp

42 Exercise ,,,. Exercise Fibonacci. Exercise n n n. 3.15,, read, write.,. f f^.,,., f^ f, eof (f) true, false.. reset(f,filename),., f f^. f eof(f) false. f f^, eof(f) true. rewrite(f,filename) f, reset(f)., eof(f) true. get(f).,.,, eof(f) true. put(f)., eof(f) true. eof(f) true,., get(f), put(f) read, write.,. read(f,x): x := f^ ; get(f) write(f,x): f^ := x ; put(f) Example , integer,. Id: P7.tex,v /04/21 02:15:10 naito Exp

43 67 var f : file of integer ; i, n : integer ; rewrite(f, integer_file ) ; for i:=1 to 10 do write(f,i) ; close(f) ; reset(f, integer_file ) ; while (not(eof(f))) do read(f,i) ; writeln(i) ; end ; close(f) OS. close(f), SPARCompiler,., open, reset, rewrite. PASCAL OS,, OS, , writeln, readln, eoln. eoln(f) f. true,. writeln(f,x) f, x,.,. readln(f,x) f, x,..,, writeln, readln., SPARCompiler errout read, readln read, readln, read(file,v1,v2,v3).,, v1, v2, v write, writeln write, writeln, write(file,v1,v2,v3)., v1, v2, v3.,,, Id: P7.tex,v /04/21 02:15:10 naito Exp

44 68 e:a:b., A, B, default. e,,,,,, , e:a, (A 1), e , e:a, e,., L. 1. A >L. (A L). e. 2. A L. e A , e:a, e true false., A.,, , e:a, e, A,. 1. A IntDigit +1. (A IntDigit 1), e, -, IntDigit abs(e) 2. A < IntDigit +1. e, -, IntDigit abs(e), IntDigit,. Id: P7.tex,v /04/21 02:15:10 naito Exp

45 , e:a, e, A,.. e <0, ewritten > 0 -,, ewritten,., ewritten DecPlaces, e E, ExpValue, ExpValue < 0 -, +, ExpValue ExpDigit. 0., ExpDigit. ewritten, DecPlace, ExpValue,. X, TenPower(X) 10 X ( ). X, RealSize(X), Z: TenPower(Z-1) abs(x) < TenPower(z). X, Y, Truncate(X,Y) X Y.., ActWidth if A >= ExpDigit + 6 then ActWidth := A else ActWidth := ExpDigit + 6 ;., ewritten, DecPlace, ExpValue, DecPlace := ActWidth - ExpDigit - 5 ; if e = 0.0 then ewritten := 0.0 ; Expvalue = 0 end else ewritten := abs(e) ; ExpValue := RealSize(eWritten) - 1 ; ewritten := ewritten / TenPower(ExpValue) ; ewritten := ewritten * TenPower(-DecPlace) ; if ewritten >= 10.0 then ewritten := ewritten / 10.0 ; ExpValue := ExpValue + 1 ; end ; ewritten := Truncate(eWritten,DecPlace) ; Example , writeln(x:9), 1.03e+10. ExpDigit = 2, ActWidth = 9, DecPlace = 2, ewritten = , ExpValue = 1. 9,,, e, = 3., = 4. Id: P7.tex,v /04/21 02:15:10 naito Exp

46 e:a:b, e, A,. A MinNumChar (A MinNumChar),. e <0, ewritten > 0 -, ewritten IntDigit,., ewritten B., ExpDigit. ewritten,. TenPower, RealSize, Truncate., ewritten, if e = 0.0 then ewritten := 0.0 end else ewritten := abs(e) ; ewritten := ewritten * TenPower(-B) ; ewritten := Truncate(eWritten,B) ;, IntDigit, if RealSize(eWritten) < 1 then IntDigit = 1 else IntDigit = RealSize(eWritten) ; MinNumChar, MinNumChar := IntDigit + B + 1 ; if (e < 0.0) and (ewritten > 0) then MinNumChar := MinNumChar + 1 ; Example , writeln(x:3:1), x:3:1 3,, 1. ExpDigit = 2, ewritten = 10.3, IntDigit = 2, MinNumChr = 4., 3+1=4., writeln(10.25:3:1) 10.2, writeln( :3:1) Remark SPARCompiler, writeln. SPARCompiler Exercise Exercise ,,. Exercise ,,,.,,., ASCII. Id: P8.tex,v /04/21 02:17:03 naito Exp

47 , (list), (tree).,,,.,, ,.,.,., ,.,., ,.,.,,. Example ,. Id: P8.tex,v /04/21 02:17:03 naito Exp

48 72 type link = ^data ; data = record str : integer ; next : link ; end ;,. Example Example ,.,, new.,,,. program list (output) ; type link = ^data ; data = record str : integer ; next : link ; end ; var first, p, q : link ; i : integer ; new(first) ; first^.next := nil ; for i:= 1 to 10 do new(p) ; p^.next := first ; p^.str := i ; first := p ; end ; q := p ; while(q^.next <> nil) do writeln(q^.str) ; q := q^.next ; end;,, next,. Example ,. Id: P8.tex,v /04/21 02:17:03 naito Exp

49 73 program list (output) ; type link = ^data ; data = record str : integer ; next : link ; end ; var first, p, q, r : link ; i : integer ; new(first) ; first^.next := nil ; for i:= 1 to 10 do new(p) ; p^.next := first ; p^.str := i ; first := p ; end ; q := p ; while(q^.next <> nil) do writeln(q^.str) ; q := q^.next ; end; writeln ; new(r) ; r^.str := 11 ; q := p ; q := p^.next ; r^.next := q^.next^.next ; q^.next := r ; q := p ; while(q^.next <> nil) do writeln(q^.str) ; q := q^.next ; end;,. p p^.next p r^.next r,, dispose. Example ,. Id: P8.tex,v /04/21 02:17:03 naito Exp

50 74 type link = ^data ; data = record str : integer ; lnext : link ; rnext : link ; end; Exercise ,, ID,,, (format). : xxxxx ID : xxxxx : xxxxx, 100. Exercise Exercise ,. 3.17, PASCAL page(f) f, abs(x) x. x. x. sqr(x) x. x. x. sqrt(x) x. x.. sin(x) sin(x). x.. cos(x) cos(x). x.. arctan(x) arctan(x). x.. exp(x) exp(x). x.. ln(x) log e (x). x odd(x) x. x.. Id: P-etc.tex,v /04/21 02:17:25 naito Exp

51 SPARCompiler, JIS,.,. Pascal,, C "., JIS 0x4027,, C, 0x22., EUC. UNIX EUC, nkf. nkf,.,. % nkf -e filename > eucfile, -e EUC ,. SPARCompiler PASCAL,, dbx. Example program test (input,output) ; var i : integer ; read(i) ;, integer,,. standard input : Bad data found on integer read ***./a.out terminated by signal 5: trace/breakpoint trap *** Traceback being written to a.out.trace, a.out,,,.,, quit., dbx.trace. Id: P-etc.tex,v /04/21 02:17:25 naito Exp

note.dvi

note.dvi II 111 5 PASCAL 5.1 Pascal, Pascal, Pascal,.,,.. 5.2 Pascal Pascal N. Wirth,..,,.,,,., Sun Microsystems SPRACompiler, ISO Pascal,., Jensen Wirth [1] ISO [2]. 5.3 Pascal Pascal,.,.,.. test.p,.p..,,. 5.4

More information

Pascal Pascal Free Pascal CPad for Pascal Microsoft Windows OS Pascal

Pascal Pascal Free Pascal CPad for Pascal Microsoft Windows OS Pascal Pascal Pascal Pascal Free Pascal CPad for Pascal Microsoft Windows OS 2010 10 1 Pascal 2 1.1.......................... 2 1.2.................. 2 1.3........................ 3 2 4 2.1................................

More information

Copyright c 2008 Zhenjiang Hu, All Right Reserved.

Copyright c 2008 Zhenjiang Hu, All Right Reserved. 2008 10 27 Copyright c 2008 Zhenjiang Hu, All Right Reserved. (Bool) True False data Bool = False True Remark: not :: Bool Bool not False = True not True = False (Pattern matching) (Rewriting rules) not

More information

橡挿入法の実践

橡挿入法の実践 PAGE:1 7JFC1121 PAGE:2 7JFC1121 PAGE:3 7JFC1121 Kadai_1.pas program input_file;{7jfc1121 19 20 { type item = record id : integer; math : integer; english : integer; var wfile data flag id_no filename :

More information

橡ソート手順比較

橡ソート手順比較 PAGE:1 [Page] 20 1 20 20 QuickSort 21 QuickSort 21 21 22 QuickSort 22 QuickSort 22 23 0 23 QuickSort 23 QuickSort 24 Order 25 25 26 26 7 26 QuickSort 27 PAGE:2 PAGE:3 program sort; { { type item = record

More information

コンピュータ概論

コンピュータ概論 4.1 For Check Point 1. For 2. 4.1.1 For (For) For = To Step (Next) 4.1.1 Next 4.1.1 4.1.2 1 i 10 For Next Cells(i,1) Cells(1, 1) Cells(2, 1) Cells(10, 1) 4.1.2 50 1. 2 1 10 3. 0 360 10 sin() 4.1.2 For

More information

1. A0 A B A0 A : A1,...,A5 B : B1,...,B

1. A0 A B A0 A : A1,...,A5 B : B1,...,B 1. A0 A B A0 A : A1,...,A5 B : B1,...,B12 2. 3. 4. 5. A0 A B f : A B 4 (i) f (ii) f (iii) C 2 g, h: C A f g = f h g = h (iv) C 2 g, h: B C g f = h f g = h 4 (1) (i) (iii) (2) (iii) (i) (3) (ii) (iv) (4)

More information

1. A0 A B A0 A : A1,...,A5 B : B1,...,B12 2. 5 3. 4. 5. A0 (1) A, B A B f K K A ϕ 1, ϕ 2 f ϕ 1 = f ϕ 2 ϕ 1 = ϕ 2 (2) N A 1, A 2, A 3,... N A n X N n X N, A n N n=1 1 A1 d (d 2) A (, k A k = O), A O. f

More information

6-1

6-1 6-1 (data type) 6-2 6-3 ML, Haskell, Scala Lisp, Prolog (setq x 123) (+ x 456) (setq x "abc") (+ x 456) ; 6-4 ( ) subtype INDEX is INTEGER range -10..10; type DAY is (MON, TUE, WED, THU, FRI, SAT, SUN);

More information

Fortran90/95 [9]! (1 ) " " 5 "Hello!"! 3. (line) Fortran Fortran 1 2 * (1 ) 132 ( ) * 2 ( Fortran ) Fortran ,6 (continuation line) 1

Fortran90/95 [9]! (1 )   5 Hello!! 3. (line) Fortran Fortran 1 2 * (1 ) 132 ( ) * 2 ( Fortran ) Fortran ,6 (continuation line) 1 Fortran90/95 2.1 Fortran 2-1 Hello! 1 program example2_01! end program 2! first test program ( ) 3 implicit none! 4 5 write(*,*) "Hello!"! write Hello! 6 7 stop! 8 end program example2_01 1 program 1!

More information

all.dvi

all.dvi fortran 1996 4 18 2007 6 11 2012 11 12 1 3 1.1..................................... 3 1.2.............................. 3 2 fortran I 5 2.1 write................................ 5 2.2.................................

More information

第10回 コーディングと統合(WWW用).PDF

第10回 コーディングと統合(WWW用).PDF 10 January 8, 2004 algorithm algorithm algorithm (unit testing) (integrated testing) (acceptance testing) Big-Bang (incremental development) (goto goto DO 50 I=1,COUNT IF (ERROR1) GO TO 60 IF (ERROR2)

More information

joho09.ppt

joho09.ppt s M B e E s: (+ or -) M: B: (=2) e: E: ax 2 + bx + c = 0 y = ax 2 + bx + c x a, b y +/- [a, b] a, b y (a+b) / 2 1-2 1-3 x 1 A a, b y 1. 2. a, b 3. for Loop (b-a)/ 4. y=a*x*x + b*x + c 5. y==0.0 y (y2)

More information

ex12.dvi

ex12.dvi 1 0. C, char., char, 0,. C, ("),., char str[]="abc" ; str abc.,, str 4. str 3. char str[10]="abc" ;, str 10, str 3., char s[]="abc", t[10] ;, t = s. ASCII, 0x00 0x7F, char., "abc" 3, 1. 1 8 256, 2., 2

More information

n 第1章 章立ての部分は、書式(PC入門大見出し)を使います

n 第1章 章立ての部分は、書式(PC入門大見出し)を使います FORTRAN FORTRAN FORTRAN ) DO DO IF IF FORTRAN FORTRAN(FORmula TRANslator)1956 IBM FORTRAN IV FORTRAN77 Fortran90 FORTRAN77 FORTRAN FORTARN IF, DO C UNIX FORTRAN PASCAL COBOL PL/I BASIC Lisp PROLOG Lisp

More information

xl 1 program Othello6; 2 {$APPTYPE CONSOLE} 3 uses SysUtils; 4 5 type 6 TMasuNo = 0..99; // 7 TYouso = (Soto,Kara,Kuro,Siro); // 8 TBan = array [TMasu

xl 1 program Othello6; 2 {$APPTYPE CONSOLE} 3 uses SysUtils; 4 5 type 6 TMasuNo = 0..99; // 7 TYouso = (Soto,Kara,Kuro,Siro); // 8 TBan = array [TMasu xl 1 program Othello6; 2 {$APPTYPE CONSOLE 3 uses SysUtils; 4 5 type 6 TMasuNo = 0..99; // 7 TYouso = (Soto,Kara,Kuro,Siro); // 8 TBan = array [TMasuNo] of TYouso; // 10 10 9 TPlayer = Kuro..Siro; // 10

More information

Excel ではじめる数値解析 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 初版 1 刷発行時のものです.

Excel ではじめる数値解析 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます.   このサンプルページの内容は, 初版 1 刷発行時のものです. Excel ではじめる数値解析 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. http://www.morikita.co.jp/books/mid/009631 このサンプルページの内容は, 初版 1 刷発行時のものです. Excel URL http://www.morikita.co.jp/books/mid/009631 i Microsoft Windows

More information

1. A0 A B A0 A : A1,...,A5 B : B1,...,B

1. A0 A B A0 A : A1,...,A5 B : B1,...,B 1. A0 A B A0 A : A1,...,A5 B : B1,...,B12 2. 3. 4. 5. A0 A, B Z Z m, n Z m n m, n A m, n B m=n (1) A, B (2) A B = A B = Z/ π : Z Z/ (3) A B Z/ (4) Z/ A, B (5) f : Z Z f(n) = n f = g π g : Z/ Z A, B (6)

More information

1.ppt

1.ppt /* * Program name: hello.c */ #include int main() { printf( hello, world\n ); return 0; /* * Program name: Hello.java */ import java.io.*; class Hello { public static void main(string[] arg)

More information

(Basic Theory of Information Processing) Fortran Fortan Fortan Fortan 1

(Basic Theory of Information Processing) Fortran Fortan Fortan Fortan 1 (Basic Theory of Information Processing) Fortran Fortan Fortan Fortan 1 17 Fortran Formular Tranlator Lapack Fortran FORTRAN, FORTRAN66, FORTRAN77, FORTRAN90, FORTRAN95 17.1 A Z ( ) 0 9, _, =, +, -, *,

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

# let st1 = {name = "Taro Yamada"; id = };; val st1 : student = {name="taro Yamada"; id=123456} { 1 = 1 ;...; n = n } # let string_of_student {n

# let st1 = {name = Taro Yamada; id = };; val st1 : student = {name=taro Yamada; id=123456} { 1 = 1 ;...; n = n } # let string_of_student {n II 6 / : 2001 11 21 (OCaml ) 1 (field) name id type # type student = {name : string; id : int};; type student = { name : string; id : int; } student {} type = { 1 : 1 ;...; n : n } { 1 = 1 ;...; n = n

More information

mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( )

mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( ) 2008 3 10 1 mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( ) stream FILE ( man ) 40 ( ) %./a.out String : test

More information

ex14.dvi

ex14.dvi 1,, 0, b (b b 2 b ) n k n = n j b j, (0 n j b 1), n =(n k n k 1...n 1 n 0 ) b, n j j j +1, 0,...,b 1 (digit). b b, n b 1 ñ, ñ = k (b 1 n j )b j b N, n b n, n = b N n, n =ñ+1 b N, n m n + m (mod b N ),

More information

2005 D Pascal CASL ( ) Pascal C 3. A A Pascal TA TA TA

2005 D Pascal CASL ( ) Pascal C 3. A A Pascal TA TA TA 2005 D 1 1.1 1.2 Pascal CASL ( ) Pascal 1. 2005 10 13 2006 1 19 12 2. C 3. A A 2 1 2 Pascal 1.3 1. 2. TA TA TA sdate@ist.osaka-u.ac.jp nakamoto@image.med.osaka-u.ac.jp h-kido@ist.osaka-u.ac.jp m-nakata@ist.osaka-u.ac.jp

More information

卒 業 研 究 報 告.PDF

卒 業 研 究 報 告.PDF C 13 2 9 1 1-1. 1-2. 2 2-1. 2-2. 2-3. 2-4. 3 3-1. 3-2. 3-3. 3-4. 3-5. 3-5-1. 3-5-2. 3-6. 3-6-1. 3-6-2. 4 5 6 7-1 - 1 1 1-1. 1-2. ++ Lisp Pascal Java Purl HTML Windows - 2-2 2 2-1. 1972 D.M. (Dennis M Ritchie)

More information

N88 BASIC 0.3 C: My Documents 0.6: 0.3: (R) (G) : enterreturn : (F) BA- SIC.bas 0.8: (V) 0.9: 0.5:

N88 BASIC 0.3 C: My Documents 0.6: 0.3: (R) (G) : enterreturn : (F) BA- SIC.bas 0.8: (V) 0.9: 0.5: BASIC 20 4 10 0 N88 Basic 1 0.0 N88 Basic..................................... 1 0.1............................................... 3 1 4 2 5 3 6 4 7 5 10 6 13 7 14 0 N88 Basic 0.0 N88 Basic 0.1: N88Basic

More information

XpressMemoForDash.dvi

XpressMemoForDash.dvi Xpress-MP 1 Ver 1.1 2006. 2. 16 (Ver1.0) 2006. 3. 1 (Ver1.1) 1 2006 3 Xpress-MP Xpress-MP 2006 Xpress-MP,. Dash [1]. mosel,, mosel.,,?, shokosv Xpress-MP,., 2. Example. 1 Xpress-MP 2 mosel 3 mosel 4, shakosv

More information

untitled

untitled Fortran90 ( ) 17 12 29 1 Fortran90 Fortran90 FORTRAN77 Fortran90 1 Fortran90 module 1.1 Windows Windows UNIX Cygwin (http://www.cygwin.com) C\: Install Cygwin f77 emacs latex ps2eps dvips Fortran90 Intel

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

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

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 tutimura@mist.i.u-tokyo.ac.jp kaneko@ipl.t.u-tokyo.ac.jp http://www.misojiro.t.u-tokyo.ac.jp/ tutimura/sem3/ 2002 12 11 p.1/33 10/16 1. 10/23 2. 10/30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20

More information

double float

double float 2015 3 13 1 2 2 3 2.1.......................... 3 2.2............................. 3 3 4 3.1............................... 4 3.2 double float......................... 5 3.3 main.......................

More information

ex01.dvi

ex01.dvi ,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) { double

More information

Copyright c 2006 Zhenjiang Hu, All Right Reserved.

Copyright c 2006 Zhenjiang Hu, All Right Reserved. 1 2006 Copyright c 2006 Zhenjiang Hu, All Right Reserved. 2 ( ) 3 (T 1, T 2 ) T 1 T 2 (17.3, 3) :: (Float, Int) (3, 6) :: (Int, Int) (True, (+)) :: (Bool, Int Int Int) 4 (, ) (, ) :: a b (a, b) (,) x y

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

num2.dvi

num2.dvi kanenko@mbk.nifty.com http://kanenko.a.la9.jp/ 16 32...... h 0 h = ε () 0 ( ) 0 1 IEEE754 (ieee754.c Kerosoft Ltd.!) 1 2 : OS! : WindowsXP ( ) : X Window xcalc.. (,.) C double 10,??? 3 :, ( ) : BASIC,

More information

A/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B

A/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B A/B (2018/10/19) Ver. 1.0 kurino@math.cst.nihon-u.ac.jp http://edu-gw2.math.cst.nihon-u.ac.jp/ kurino/2018/soft/soft.html 2018 10 19 A/B 1 2018 10 19 2 1 1 1.1 OHP.................................... 1

More information

:30 12:00 I. I VI II. III. IV. a d V. VI

:30 12:00 I. I VI II. III. IV. a d V. VI 2017 2017 08 03 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF X [ S ] a S S ; X X X, S [, a, ], ; BNF X (parse tree) (1) [a;a] (2) [[a]] (3) [a;[a]] (4) [[a];a] : [a] X 2 222222

More information

tuat1.dvi

tuat1.dvi ( 1 ) http://ist.ksc.kwansei.ac.jp/ tutimura/ 2012 6 23 ( 1 ) 1 / 58 C ( 1 ) 2 / 58 2008 9 2002 2005 T E X ptetex3, ptexlive pt E X UTF-8 xdvi-jp 3 ( 1 ) 3 / 58 ( 1 ) 4 / 58 C,... ( 1 ) 5 / 58 6/23( )

More information

2009 D Pascal CASL II ( ) Pascal C 3. A A Pascal TA TA

2009 D Pascal CASL II ( ) Pascal C 3. A A Pascal TA TA 2009 D 1 1.1 1.2 Pascal CASL II ( ) Pascal 1. 2009 10 15 2010 1 29 16 2. C 3. A A 2 1 2 Pascal 1.3 1. 2. TA enshud@image.med.osaka-u.ac.jp TA enshu-d@image.med.osaka-u.ac.jp nakamoto@image.med.osaka-u.ac.jp

More information

新版明解C言語 実践編

新版明解C言語 実践編 2 List - "max.h" a, b max List - max "max.h" #define max(a, b) ((a) > (b)? (a) : (b)) max List -2 List -2 max #include "max.h" int x, y; printf("x"); printf("y"); scanf("%d", &x); scanf("%d", &y); printf("max(x,

More information

2011 D Pascal CASL II ( ) Pascal C 3. A A Pascal TA TA enshu-

2011 D Pascal CASL II ( ) Pascal C 3. A A Pascal TA TA enshu- 2011 D 1 1.1 1.2 Pascal CASL II ( ) Pascal 1. 2011 10 6 2011 2 9 15 2. C 3. A A 2 1 2 Pascal 1.3 1. 2. TA enshud@fenrir.ics.es.osaka-u.ac.jp TA enshu-d@fenrir.ics.es.osaka-u.ac.jp higo@ist.osaka-u.ac.jp

More information

[ 1] 1 Hello World!! 1 #include <s t d i o. h> 2 3 int main ( ) { 4 5 p r i n t f ( H e l l o World!! \ n ) ; 6 7 return 0 ; 8 } 1:

[ 1] 1 Hello World!! 1 #include <s t d i o. h> 2 3 int main ( ) { 4 5 p r i n t f ( H e l l o World!! \ n ) ; 6 7 return 0 ; 8 } 1: 005 9 7 1 1.1 1 Hello World!! 5 p r i n t f ( H e l l o World!! \ n ) ; 7 return 0 ; 8 } 1: 1 [ ] Hello World!! from Akita National College of Technology. 1 : 5 p r i n t f ( H e l l o World!! \ n ) ;

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

超初心者用

超初心者用 3 1999 10 13 1. 2. hello.c printf( Hello, world! n ); cc hello.c a.out./a.out Hello, world printf( Hello, world! n ); 2 Hello, world printf n printf 3. ( ) int num; num = 100; num 100 100 num int num num

More information

untitled

untitled II yacc 005 : 1, 1 1 1 %{ int lineno=0; 3 int wordno=0; 4 int charno=0; 5 6 %} 7 8 %% 9 [ \t]+ { charno+=strlen(yytext); } 10 "\n" { lineno++; charno++; } 11 [^ \t\n]+ { wordno++; charno+=strlen(yytext);}

More information

????? 1???

????? 1??? SUN MON TUE WED THU FRI SAT SUN MON TUE WED THU FRI SAT SUN MON TUE WED THU FRI SAT SUN MON TUE WED THU FRI SAT SUN MON TUE WED THU FRI SAT SUN MON TUE WED THU FRI SAT SUN MON TUE WED THU FRI SAT SUN MON

More information

II ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D

II ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D II 8 2003 11 12 1 6 ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 Daisuke 8 =>. 73 Daisuke 35 Hiroshi 64 Ichiro 87 Junko

More information

program.dvi

program.dvi 2001.06.19 1 programming semi ver.1.0 2001.06.19 1 GA SA 2 A 2.1 valuename = value value name = valuename # ; Fig. 1 #-----GA parameter popsize = 200 mutation rate = 0.01 crossover rate = 1.0 generation

More information

B Simon (Trump ) SimonU.pas SimonP.dpr Name FormSimon Caption Position podesktopcenter uses Windows, Messages, SysUtils,

B Simon (Trump ) SimonU.pas SimonP.dpr Name FormSimon Caption Position podesktopcenter uses Windows, Messages, SysUtils, B 132 20 1 1 20.1 20.1.1 1 52 10 1 2 3... 7 8 8 8 20.1.2 1 5 6 7 3 20.1.3 1 3 8 20.1.4 13 20.1.5 4 1 (solitaire) B 133 20.2 20.2.1 Simon (Trump ) SimonU.pas SimonP.dpr 20.2.2 Name FormSimon Caption Position

More information

Condition DAQ condition condition 2 3 XML key value

Condition DAQ condition condition 2 3 XML key value Condition DAQ condition 2009 6 10 2009 7 2 2009 7 3 2010 8 3 1 2 2 condition 2 3 XML key value 3 4 4 4.1............................. 5 4.2...................... 5 5 6 6 Makefile 7 7 9 7.1 Condition.h.............................

More information

新・明解C言語 実践編

新・明解C言語 実践編 第 1 章 見 21 1-1 見えないエラー 見 List 1-1 "max2x1.h" a, b max2 List 1-1 chap01/max2x1.h max2 "max2x1.h" #define max2(a, b) ((a) > (b)? (a) : (b)) max2 List 1-2 List 1-2 chap01/max2x1test.c max2 #include

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

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

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

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I  Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~alse I Exercise on Programming I http://bit.ly/oitprog1 1, 2 of 14 ( RD S ) I 1, 2 of 14 1 / 44 Ruby Ruby ( RD S ) I 1, 2 of 14 2 / 44 7 5 9 2 9 3 3 2 6 5 1 3 2 5 6 4 7 8 4 5 2 7 9 6 4 7 1 3 ( RD S ) I 1, 2

More information

haskell.gby

haskell.gby Haskell 1 2 3 Haskell ( ) 4 Haskell Lisper 5 Haskell = Haskell 6 Haskell Haskell... 7 qsort [8,2,5,1] [1,2,5,8] "Hello, " ++ "world!" "Hello, world!" 1 + 2 div 8 2 (+) 1 2 8 div 2 3 4 map even [1,2,3,4]

More information

BASICとVisual Basic

BASICとVisual Basic Visual Basic BASIC Visual Basic BASICBeginner's All purpose Symbolic Instruction Code Visual Basic Windows BASIC BASIC Visual Basic Visual Basic End Sub .Visual Basic Visual Basic VB 1-1.Visual Basic

More information

r03.dvi

r03.dvi 19 ( ) 019.4.0 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void... argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0 a a \0 b b b \0 c c c \0 1: // argdemo1.c ---

More information

I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) + x * x + x x (4) * *

I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) + x * x + x x (4) * * 2015 2015 07 30 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) +

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

:30 12:00 I. I VI II. III. IV. a d V. VI

:30 12:00 I. I VI II. III. IV. a d V. VI 2018 2018 08 02 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF N N y N x N xy yx : yxxyxy N N x, y N (parse tree) (1) yxyyx (2) xyxyxy (3) yxxyxyy (4) yxxxyxxy N y N x N yx

More information

ohp03.dvi

ohp03.dvi 19 3 ( ) 2019.4.20 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void int main(int argc, char *argv[]) {... 2 (2) argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0

More information

‚æ4›ñ

‚æ4›ñ ( ) ( ) ( ) A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 (OUS) 9 26 1 / 28 ( ) ( ) ( ) A B C D Z a b c d z 0 1 2 9 (OUS) 9

More information

( ) 1 Windows HTML ( ) ( ) ( ) WWW 10 ( )

( ) 1 Windows HTML ( ) ( ) ( ) WWW 10 ( ) ( ) 1 Windows HTML ( ) ( ) ( ) 1. 2. 3. 4. WWW 10 ( ) 2 1. 2. 1 3. ( ) 4. 5. 3 Windows 2 7 8 MS Word MS Excel 1. MS Word 600 2. MS Excel 1 34 2 83 3 23 4 70 5 100 6 45 7 58 8 29 9 68 10 72 11 37 12 12

More information

基礎情報処理 I (文字型)

基礎情報処理 I (文字型) プログラミング 1 ( 文字型 ) program character1; a,b,c: char; writeln('1 文字づつ3 文字入力してください :'); readln(a); readln(b); readln(c); write(a); write(b); write(c); writeln; a,b,c:char; a:='a'; b:='b'; c:='c'; write(a);

More information

A/B (2010/10/08) Ver kurino/2010/soft/soft.html A/B

A/B (2010/10/08) Ver kurino/2010/soft/soft.html A/B A/B (2010/10/08) Ver. 1.0 kurino@math.cst.nihon-u.ac.jp http://edu-gw2.math.cst.nihon-u.ac.jp/ kurino/2010/soft/soft.html 2010 10 8 A/B 1 2010 10 8 2 1 1 1.1 OHP.................................... 1 1.2.......................................

More information

(2000 )

(2000 ) (000) < > = = = (BC 67» BC 1) 3.14 10 (= ) 18 ( 00 ) ( ¼"½ '"½ &) ¼ 18 ¼ 0 ¼ =3:141596535897933846 ¼ 1 5cm ` ¼ = ` 5 = ` 10 () ` =10¼ (cm) (1) 3cm () r () () (1) r () r 1 4 (3) r, 60 ± 1 < > µ AB ` µ ±

More information

. (.8.). t + t m ü(t + t) + c u(t + t) + k u(t + t) = f(t + t) () m ü f. () c u k u t + t u Taylor t 3 u(t + t) = u(t) + t! u(t) + ( t)! = u(t) + t u(

. (.8.). t + t m ü(t + t) + c u(t + t) + k u(t + t) = f(t + t) () m ü f. () c u k u t + t u Taylor t 3 u(t + t) = u(t) + t! u(t) + ( t)! = u(t) + t u( 3 8. (.8.)............................................................................................3.............................................4 Nermark β..........................................

More information

For_Beginners_CAPL.indd

For_Beginners_CAPL.indd CAPL Vector Japan Co., Ltd. 目次 1 CAPL 03 2 CAPL 03 3 CAPL 03 4 CAPL 04 4.1 CAPL 4.2 CAPL 4.3 07 5 CAPL 08 5.1 CANoe 5.2 CANalyzer 6 CAPL 10 7 CAPL 11 7.1 CAPL 7.2 CAPL 7.3 CAPL 7.4 CAPL 16 7.5 18 8 CAPL

More information

untitled

untitled II 4 Yacc Lex 2005 : 0 1 Yacc 20 Lex 1 20 traverse 1 %% 2 [0-9]+ { yylval.val = atoi((char*)yytext); return NUM; 3 "+" { return + ; 4 "*" { return * ; 5 "-" { return - ; 6 "/" { return / ; 7 [ \t] { /*

More information

GraphicsWithPlotFull.nb Plot[{( 1), ( ),...}, {( ), ( ), ( )}] Plot Plot Cos x Sin x, x, 5 Π, 5 Π, AxesLabel x, y x 1 Plot AxesLabel

GraphicsWithPlotFull.nb Plot[{( 1), ( ),...}, {( ), ( ), ( )}] Plot Plot Cos x Sin x, x, 5 Π, 5 Π, AxesLabel x, y x 1 Plot AxesLabel http://yktlab.cis.k.hosei.ac.jp/wiki/ 1(Plot) f x x x 1 1 x x ( )[( 1)_, ( )_, ( 3)_,...]=( ) Plot Plot f x, x, 5, 3 15 10 5 Plot[( ), {( ), ( ), ( )}] D g x x 3 x 3 Plot f x, g x, x, 10, 8 00 100 10 5

More information

y = x 4 y = x 8 3 y = x 4 y = x 3. 4 f(x) = x y = f(x) 4 x =,, 3, 4, 5 5 f(x) f() = f() = 3 f(3) = 3 4 f(4) = 4 *3 S S = f() + f() + f(3) + f(4) () *4

y = x 4 y = x 8 3 y = x 4 y = x 3. 4 f(x) = x y = f(x) 4 x =,, 3, 4, 5 5 f(x) f() = f() = 3 f(3) = 3 4 f(4) = 4 *3 S S = f() + f() + f(3) + f(4) () *4 Simpson H4 BioS. Simpson 3 3 0 x. β α (β α)3 (x α)(x β)dx = () * * x * * ɛ δ y = x 4 y = x 8 3 y = x 4 y = x 3. 4 f(x) = x y = f(x) 4 x =,, 3, 4, 5 5 f(x) f() = f() = 3 f(3) = 3 4 f(4) = 4 *3 S S = f()

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

netcdf

netcdf 1. Anetcdf.rb netcdf C ruby open new create NetCDF C filename String NetCDF NetCDF_open mode r r, w share false true or false open open netcdf filename String NetCDF NetCDF_create noclobber false true

More information

1,.,,,., RDBM, SQL. OSS,, SQL,,.

1,.,,,., RDBM, SQL. OSS,, SQL,,. 1,.,,,., RDBM, SQL. OSS,, SQL,,. 3 10 10 OSS RDBMS SQL 11 10.1 OSS RDBMS............................ 11 10.1.1 PostgreSQL................................. 11 10.1.2 MySQL...................................

More information

PBASIC 2.5 PBASIC 2.5 $PBASIC directive PIN type New DEBUG control characters DEBUGIN Line continuation for comma-delimited lists IF THEN ELSE * SELEC

PBASIC 2.5 PBASIC 2.5 $PBASIC directive PIN type New DEBUG control characters DEBUGIN Line continuation for comma-delimited lists IF THEN ELSE * SELEC PBASIC 2.5 PBASIC 2.5 BASIC Stamp Editor / Development System Version 2.0 Beta Release 2 2.0 PBASIC BASIC StampR PBASIC PBASIC PBASIC 2.5 Parallax, Inc. PBASIC 2.5 PBASIC 2.5 support@microbot-ed.com 1

More information

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU 1. 1.1. 1.2. 1 PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU 2. 2.1. 2 1 2 C a b N: PC BC c 3C ac b 3 4 a F7 b Y c 6 5 a ctrl+f5) 4 2.2. main 2.3. main 2.4. 3 4 5 6 7 printf printf

More information

z-tree 2005 4 1 1 4 1.1............................ 4 1.2.............................. 5 1.3......................................... 5 1.4............................................. 5 1.5................................

More information

★結果★ 藤沢市長杯 掲示用ヒート表

★結果★ 藤沢市長杯 掲示用ヒート表 AA 35 Round 1 8 4 Round 2 28 16 SEMI FINAL H1 H5 H1 H1 Red 12802015 1 Red 12802109 1 1-1 Red 12802015 2 1-1 Red 12702346 White 12800232 2 White 12702406 3 3-1 White 12702346 1 3-1 White 12802109 Yellow

More information

ストラドプロシージャの呼び出し方

ストラドプロシージャの呼び出し方 Release10.5 Oracle DataServer Informix MS SQL NXJ SQL JDBC Java JDBC NXJ : NXJ JDBC / NXJ EXEC SQL [USING CONNECTION ] CALL [.][.] ([])

More information

lexex.dvi

lexex.dvi (2018, c ) http://istksckwanseiacjp/ ishiura/cpl/ 4 41 1 mini-c lexc,, 2 testlexc, lexc mini-c 1 ( ) mini-c ( ) (int, char, if, else, while, return 6 ) ( ) (+, -, *, /, %, &, =, ==,!=, >, >=,

More information

18 C ( ) hello world.c 1 #include <stdio.h> 2 3 main() 4 { 5 printf("hello World\n"); 6 } [ ] [ ] #include <stdio.h> % cc hello_world.c %./a.o

18 C ( ) hello world.c 1 #include <stdio.h> 2 3 main() 4 { 5 printf(hello World\n); 6 } [ ] [ ] #include <stdio.h> % cc hello_world.c %./a.o 18 C ( ) 1 1 1.1 hello world.c 5 printf("hello World\n"); 6 } [ ] [ ] #include % cc hello_world.c %./a.out Hello World [a.out ] % cc hello_world.c -o hello_world [ ( ) ] (K&R 4.1.1) #include

More information

listings-ext

listings-ext (6) Python (2) ( ) ohsaki@kwansei.ac.jp 5 Python (2) 1 5.1 (statement)........................... 1 5.2 (scope)......................... 11 5.3 (subroutine).................... 14 5 Python (2) Python 5.1

More information

Original : Hello World! (0x0xbfab85e0) Copy : Hello World! (0x0x804a050) fgets mstrcpy malloc mstrcpy (main ) mstrcpy malloc free fgets stream 1 ( \n

Original : Hello World! (0x0xbfab85e0) Copy : Hello World! (0x0x804a050) fgets mstrcpy malloc mstrcpy (main ) mstrcpy malloc free fgets stream 1 ( \n 2008 3 10 1 mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( ) stream FILE ( man ) 40 ( ) %./a.out String : test

More information

1 C STL(1) C C C libc C C C++ STL(Standard Template Library ) libc libc C++ C STL libc STL iostream Algorithm libc STL string vector l

1 C STL(1) C C C libc C C C++ STL(Standard Template Library ) libc libc C++ C STL libc STL iostream Algorithm libc STL string vector l C/C++ 2007 6 18 1 C STL(1) 2 1.1............................................... 2 1.2 stdio................................................ 3 1.3.......................................... 10 2 11 2.1 sizeof......................................

More information

C

C C 1 2 1.1........................... 2 1.2........................ 2 1.3 make................................................ 3 1.4....................................... 5 1.4.1 strip................................................

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

( 9 1 ) 1 2 1.1................................... 2 1.2................................................. 3 1.3............................................... 4 1.4...........................................

More information

2.2 Sage I 11 factor Sage Sage exit quit 1 sage : exit 2 Exiting Sage ( CPU time 0m0.06s, Wall time 2m8.71 s). 2.2 Sage Python Sage 1. Sage.sage 2. sa

2.2 Sage I 11 factor Sage Sage exit quit 1 sage : exit 2 Exiting Sage ( CPU time 0m0.06s, Wall time 2m8.71 s). 2.2 Sage Python Sage 1. Sage.sage 2. sa I 2017 11 1 SageMath SageMath( Sage ) Sage Python Sage Python Sage Maxima Maxima Sage Sage Sage Linux, Mac, Windows *1 2 Sage Sage 4 1. ( sage CUI) 2. Sage ( sage.sage ) 3. Sage ( notebook() ) 4. Sage

More information

2 A I / 58

2 A I / 58 2 A 2018.07.12 I 2 2018.07.12 1 / 58 I 2 2018.07.12 2 / 58 π-computer gnuplot 5/31 1 π-computer -X ssh π-computer gnuplot I 2 2018.07.12 3 / 58 gnuplot> gnuplot> plot sin(x) I 2 2018.07.12 4 / 58 cp -r

More information

syspro-0405.ppt

syspro-0405.ppt 3 4, 5 1 UNIX csh 2.1 bash X Window 2 grep l POSIX * more POSIX 3 UNIX. 4 first.sh #!bin/sh #first.sh #This file looks through all the files in the current #directory for the string yamada, and then prints

More information

joho07-1.ppt

joho07-1.ppt 0xbffffc5c 0xbffffc60 xxxxxxxx xxxxxxxx 00001010 00000000 00000000 00000000 01100011 00000000 00000000 00000000 xxxxxxxx x y 2 func1 func2 double func1(double y) { y = y + 5.0; return y; } double func2(double*

More information

Microsoft Word - C.....u.K...doc

Microsoft Word - C.....u.K...doc C uwêííôöðöõ Ð C ÔÖÐÖÕ ÐÊÉÌÊ C ÔÖÐÖÕÊ C ÔÖÐÖÕÊ Ç Ê Æ ~ if eíè ~ for ÒÑÒ ÌÆÊÉÉÊ ~ switch ÉeÍÈ ~ while ÒÑÒ ÊÍÍÔÖÐÖÕÊ ~ 1 C ÔÖÐÖÕ ÐÊÉÌÊ uê~ ÏÒÏÑ Ð ÓÏÖ CUI Ô ÑÊ ÏÒÏÑ ÔÖÐÖÕÎ d ÈÍÉÇÊ ÆÒ Ö ÒÐÑÒ ÊÔÎÏÖÎ d ÉÇÍÊ

More information

C言語によるアルゴリズムとデータ構造

C言語によるアルゴリズムとデータ構造 Algorithms and Data Structures in C 4 algorithm List - /* */ #include List - int main(void) { int a, b, c; int max; /* */ Ÿ 3Ÿ 2Ÿ 3 printf(""); printf(""); printf(""); scanf("%d", &a); scanf("%d",

More information

13 Student Software TI-Nspire CX CAS TI Web TI-Nspire CX CAS Student Software ( ) 1 Student Software 37 Student Software Nspire Nspire Nspir

13 Student Software TI-Nspire CX CAS TI Web TI-Nspire CX CAS Student Software ( ) 1 Student Software 37 Student Software Nspire Nspire Nspir 13 Student Software TI-Nspire CX CAS TI Web TI-Nspire CX CAS Student Software ( ) 1 Student Software 37 Student Software 37.1 37.1 Nspire Nspire Nspire 37.1: Student Software 13 2 13 Student Software esc

More information