Pascal Pascal Free Pascal CPad for Pascal Microsoft Windows OS Pascal

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

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

橡ソート手順比較


橡挿入法の実践

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

XpressMemoForDash.dvi

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

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

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

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

1 シミュレーションとは何か?

解きながら学ぶJava入門編

L N P Y F C T V W Z I X Pentomino Form Name Caption Position FormMain podesktopcenter

コンピュータ概論

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

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

untitled

) 9 81

K227 Java 2

1.ppt

VDM-SL VDM VDM-SL Toolbox VDM++ Toolbox 1 VDM-SL VDM++ Web bool

プログラミングI (手続き)

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


超初心者用

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:

Copyright c 2008 Zhenjiang Hu, All Right Reserved.

note.dvi

記号と準備

新版明解C言語 実践編

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

05秋案内.indd

Z...QXD (Page 1)

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

応用数学特論.dvi

情報科学概論 第1回資料

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


fiš„v3.dvi

num2.dvi

B 90 Canvas.Pen.Width := PenWidth; NewData; (* FormCreate (*********************** ******************* procedure TFormSorting.DrawOne(No : TDat

Copyright c 2006 Zhenjiang Hu, All Right Reserved.

11042 計算機言語7回目 サポートページ:

案内最終.indd

コンピュータ工学講義プリント (7 月 17 日 ) 今回の講義では フローチャートについて学ぶ フローチャートとはフローチャートは コンピュータプログラムの処理の流れを視覚的に表し 処理の全体像を把握しやすくするために書く図である 日本語では流れ図という 図 1 は ユーザーに 0 以上の整数 n

1. 2 P 2 (x, y) 2 x y (0, 0) R 2 = {(x, y) x, y R} x, y R P = (x, y) O = (0, 0) OP ( ) OP x x, y y ( ) x v = y ( ) x 2 1 v = P = (x, y) y ( x y ) 2 (x

Appendix A BASIC BASIC Beginner s All-purpose Symbolic Instruction Code FORTRAN COBOL C JAVA PASCAL (NEC N88-BASIC Windows BASIC (1) (2) ( ) BASIC BAS

1990 IMO 1990/1/15 1:00-4:00 1 N N N 1, N 1 N 2, N 2 N 3 N 3 2 x x + 52 = 3 x x , A, B, C 3,, A B, C 2,,,, 7, A, B, C

OS Windows Mac OS Windows Mac OS Windows XP Mac OS X OS Windows 95 Mac OS

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

45 VBA Fortran, Pascal, C Windows OS Excel VBA Visual Basic Excel VBA VBA Visual Basic For Application Microsoft Office Office Excel VBA VBA Excel Acc

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

ex01.dvi

jssst-ocaml.mgp

<リスト1> AD コンバータへのデータの出力例 NEC PC98 用 mov al,22h // CLK -> 1, CS -> 0, DI -> 0 out 32h,al // シリアル ポートにデータ出力 PC/AT 互換機用 mov al,00h // CLK -> 1 mov dx,3fb

Microsoft PowerPoint - while.ppt

syspro-0405.ppt

04年度LS民法Ⅰ教材改訂版.PDF

c-all.dvi

My関数の作成演習問題集

1 # include < stdio.h> 2 # include < string.h> 3 4 int main (){ 5 char str [222]; 6 scanf ("%s", str ); 7 int n= strlen ( str ); 8 for ( int i=n -2; i

2 X Y Y X θ 1,θ 2,... Y = f (X,θ 1,θ 2,...) θ k III 8 ( ) 1 / 39

94 expression True False expression FalseMSDN IsNumber WorksheetFunctionIsNumberexpression expression True Office support.office.com/ja-jp/ S

cpp1.dvi

Java updated

all.dvi

情報の構造とデータ処理

Informatics 2014

表紙

e ::= c op(e 1,..., e n ) if e 1 then e 2 else e 3 let x = e 1 in e 2 x let rec x y 1... y n = e 1 in e 2 e e 1... e n (e 1,..., e n ) let (x 1,..., x

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

PowerPoint プレゼンテーション

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

JavaScript 1.! DOM Ajax Shelley Powers,, JavaScript David Flanagan, JavaScript 2

B 5 (2) VBA R / B 5 ( ) / 34

漸化式のすべてのパターンを解説しましたー高校数学の達人・河見賢司のサイト

pptx

Windows Cygwin Mac *1 Emacs Ruby ( ) 1 Cygwin Bash Cygwin Windows Cygwin Cygwin Mac 1 Mac 1.2 *2 ls *3 *1 OS Linux *2 *3 Enter ( ) 2

D0050.PDF

Taro-Basicの基礎・条件分岐(公

netcdf

Parametric Polymorphism

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


1. 入力画面

ケミカルエンジニアのためのExcelを用いた化学工学計算法

A/B (2018/06/08) Ver kurino/2018/soft/soft.html A/B

A(6, 13) B(1, 1) 65 y C 2 A(2, 1) B( 3, 2) C 66 x + 2y 1 = 0 2 A(1, 1) B(3, 0) P 67 3 A(3, 3) B(1, 2) C(4, 0) (1) ABC G (2) 3 A B C P 6

Informatics 2010.key

haskell.gby

01_OpenMP_osx.indd


1F90/kouhou_hf90.dvi

joho09.ppt

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

tuat1.dvi

Lesson 1 1 EXVBA2000 Lesson01 Lesson01.xls 2

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

(1) (2) (3) (4) (1) (a) (b) (c) (d) kg 9.8 N 5.0 kg 19.6 m/s kg m/s 8.0kg (2) 1 r=1.0m ABC QA =1

Transcription:

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................................ 4 2.2................................ 5 2.3.......................... 6 2.4................................ 6 2.5................................. 7 3 7 3.1 if................................. 7 3.2 case................................ 7 4 8 4.1 for................................. 8 4.2 while............................... 9 4.3 repeat............................... 10 5 10 5.1................................ 10 5.2................................. 11 A Pascal 12 A.1 Pascal............................ 12 A.2 Pascal...................... 12 B 13 1

1 Pascal 1.1 Hello. Pascal 1.1. Hello. program Lesson1; writeln( Hello. ); 1 Pascal program ; ;() 2 () 3 Hello. 4 ()? No? Yes No 1.2 Pascal Hello. Yes PCPad.exe 2

1.3 2 a b Pascal 1.2. 2 program Lesson2; var a,b,wa:integer; write( a= ); readln(a); write( b= ); readln(b); wa:=a+b; writeln( a+b=, wa); 1 Pascal program ; ;() 2 a, b, wa 3 () 4 a= write writeln 5 a 8 a+b wa ( ) = := 9 a+b= wa 10 () Pascal program ; const type var procedure function const < >=< >; < >=< >; 1 1.3. n=10 v=2.71 10 12 name= const n=10; v=2.71e-12; name= ; Pascal 3

type < >=< >; < >=< >; 1.4. 3 vector Pascal sin function < >(>,, <>):< >; < > type vector=array[1..3] of real; 1.7. a b ( ) var < >,, < >:< >; < >,, < >:< >; 1.5. a,b x,y,r ans name 30 var a,b:integer; x,y,r:real; ans:char; name:string[30]; Pascal BASIC procedure <>(>,, <>); 1.6. a b procedure exchg(var a,b:integer); var c:integer; c:=a; a:=b; b:=c; function max(a,b:real):real; if a>b then max:=a else max:=b; BASIC FORTRAN 2 2.1 Pascal 5 byte 0 255 shortint -128 127 integer -32768 32767 word 0 65535 longint -2147483648 2147483647 2 MaxInt=32767 MaxLongInt=2147483647 2.1. 2 a, b 4

program Lesson3; var a,b,wa,sa,seki,shou,amari:integer; write( a= ); readln(a); write( b= ); readln(b); wa:=a+b; sa:=a-b; seki:=a*b; shou:=a div b; amari:=a mod b; writeln( a+b=, wa); writeln( a-b=, sa); writeln( a*b=, seki); writeln( a div b=, shou); writeln( a mod b=, amari); 2 a, b, wa, seki, shou, amari 6 a+b wa 7 a-b sa 8 a b seki 9 a div b shou 10 a mod b amari 11 a+b = wa 15 a mod b = amari 2.2 Pascal real 2.9 10 39 1.7 10 38 ( ) 11 + / : trunc(x) round(x) x ; x 2.2. v x program Lesson4; var v, x:real; h, m:integer; write( ); readln(v); write( (km) ); readln(x); h:=trunc(x/v); m:=round((x/v - h)*60); writeln(h,,m, ); 12 a-b = sa 13 a b = seki 14 a div b = shou 2 v, x 3 h, m 5

5 6 v 7 (km) 8 x 9 x/v h 10 x/v-h 60 m 11 h m n:=length(name); writeln( Length is, n); writeln( Initial is, init); 2 name 20 3 init 4 n 5 Your first name? 2.3 a,..., z A,..., Z 0,..., 9 1 : var c1,c2: char; 1 2 : var name: string[20]; 2.3. ( ) 6 name 7 init name 1 8 n name 9 Length is n 10 Initial is init 2.4 true( ) false( ) 2 : var c: boolean; program Lesson5; var name: string[20]; init: char; n: integer; write( Your first name? ); readln(name); init:=name[1]; : not, and, or, =, <>, <=, >=, <, > 2.4. a=b c d true false (a=b) and (c>=d) 6

2.5 100 100 a 1, a 2,..., a 100 Pascal a a[1], a[2],, a[100] 2.5. a 1 100 b 1 100 var a: array[1..100] of integer; b: array[1..100] of real; 3 3.1 if if if 2 : if then if then 1 else 2 3.1. else 1 ; 3.2. 2 program Lesson6; var a,b,d,x1,x2: real; writeln( x^2 + ax + b = 0 ); write( a= ); readln(a); write( b= ); readln(b); d:=a*a - 4*b; if d>=0 then 3.2 case x1:=(-a - sqrt(d))/2; x2:=(-a + sqrt(d))/2; writeln(x1:5:3); writeln(x2:5:3); end else writeln( ); 1 case case : case of case,, case : ; case,, case : ; 3.3. program Lesson7; var mon:integer; write( ); readln(mon); case mon of 3..5 : write( ); 6..8 : write( ); 9..11 : write( ); 12, 1..2 : write( ); 7

2 mon 4 5 mon 6 11 mon 3 5 mon 6 8 mon 9 11 mon 12 1 2 4 4.1 for for for 2 : for := to do ( 1 ) for := downto do ( 1 ) 4 n= n 5 s 0 6 a 1 n s s+a 7 1 +... + n s 4.2. 3 a b<c c n program Lesson9; var a,b,c,n: integer; write( n = ); readln(n); for a:=1 to n do for b:=a to n do for c:=b to n do if a*a+b*b=c*c then writeln(a:5,b:5,c:5); 4.1. 1 n program Lesson8; var a,n,s: integer; write( n = ); readln(n); s:=0; for a:=1 to n do s:=s + a; writeln( 1 +... +,n, =,s); 2 a, n, s 2 a, b, c, n 4 n= n 5 8 a 1 n b a n c b n a a+b b=c c a b c 4.3. 10 program Lesson10; const n=10; var a: array[1..n] of integer; 8

h,s,t,v:real; i,x:integer; for i:=1 to n do readln(a[i]); s:=0; for i:=1 to n do s:=s+a[i]; h:=s/n; (* *) t:=0; for i:=1 to n do t:=t+sqr(a[i]-h); v:=sqrt(t/n); (* *) writeln(h:5:2,, v:5:2); 2 n 10 3 a 1 10 4 h, s, t, v 5 i, x 7 i 1 n a i a[i] 8 s 0 9 i 1 n s s+a[i] s a[1] a[n] 10 h s/n h a[1] a[n] (* *) 11 t 0 12 i 1 n t t+(a[i]-h) 2 t (a[1]-h) 2 (a[n]-h) 2 13 v t/n v a[1] a[n] 14 h v 4.2 while while : while do 4.4. program Lesson11; var a,n,amax: integer; write( 2 ); readln(n); amax:=trunc(sqrt(n)); if n mod 2=0 then if n=2 then writeln(n, ) else writeln(n, ); end else a:=3; while (n mod a<>0) and (a<=amax) do a:=a+2; if (n mod a=0) and (n>a) then writeln(n, ) else writeln(n, ); 2 a, n, amax 4 2 n 9

5 amax n 6 n 2 0 (n ) 7 9 n=2 n n 10 n r:=a mod b; a:=b; b:=r; until b=0; writeln(,a); 2 a, b, r 11 a 3 12 n a 0 a amax a a+2 13 n a 0 n>a n 14 n 4 a= a 5 b= b 6 b>a 7 r a a b b r 4.3 repeat 9 11 r a b a b b r b 0 repeat : 12 a repeat until 4.5. program Lesson12; var a,b,r: integer; write( a = ); readln(a); write( b = ); readln(b); if b>a then r:=a; a:=b; b:=r; repeat 5 5.1 : procedure <>(>,, <>); < > var var 10

5.1. program Lesson13; type complex=array[1..2] of real; var x,y,z: complex; (* c:=a*b *) procedure compmul(var c: complex; a,b: complex); c[1]:=a[1]*b[1]-a[2]*b[2]; c[2]:=a[1]*b[2]+a[2]*b[1]; write( Re x = ); readln(x[1]); write( Im x = ); readln(x[2]); write( Re y = ); readln(y[1]); write( Im y = ); readln(y[2]); compmul(z,x,y); writeln( x*y =,z[1]:4:2, +,z[2]:4:2, i ); 2 complex 1 2 1 2 3 x, y, z complex 5 9 a b c compmu lc a b 11 Re x = x[1] 12 Im x = x[2] 13 Re y = y[1] 14 Im y = y[2] 15 compmul x y z 16 x y = z[1] + z[2] i 11 5.2 ( ): function < >(>,, <>):< >; < > 5.2. program Lesson14; var a,b,d:integer; function gcd(a,b:integer):integer; var r: integer; if b>a then r:=a; a:=b; b:=r; repeat r:=a mod b; a:=b; b:=r; until b=0; gcd:=a; (* main *) write( = ); readln(a); write( = ); readln(b);

d:=gcd(a,b); a:=a div d; b:=b div d; write(a, /,b); 2 a, b, d 3 15 gcd 4.5 14 17 = a 18 = b 19 a b d 20 a a d b b d 21 a / b A Pascal A.1 Pascal absolute end inline procedure type and external interface program unit array file interrupt record until for label repeat uses case forward mod set var const function nil shl while div goto not shr with do if of string xor downto implementation or then else in packed to A.2 Pascal i,j,n:x:a:c,ch:f: s,st:b:w:write write c, s c:n, s:n n i i 10 i:n n x x 10 x:n n x:n:j x j 10 n read(f, v,..., v) readln(f, v,..., v) write(f, w,..., w) writeln(f, w,..., w) a:=abs(a) a:=sqr(a) x:=sin(a) x:=cos(a) x:=exp(a) x:=ln(a) x:=sqrt(a) x:=arctan(a) i:=trunc(x) i:=round(x) b:=odd(i) randomize x:=random i:=random(n) 2 v true false 0.0 1.0 0 n 12

c:=chr(i) i:=ord(c) s:=copy(st,i,n) s:=concat(s 1,..., s n ) i:=length(st) i:=pos(s,st) ch:=upcase(c) delete(st,i,n) insert(s,st,i) str(w,s) val(s,a,i) st i n s 1 s n st st s ( 0 ) c st i n s st i w s s a ( i 0 s i ) B 2/10( ) ( 7F) 1. (A4 5 ) 2. 3. 4. 5. (a) (b) (c), Pascal [ 2 ],, 1992. 13