You are on page 1of 45

, 2006


1. ..........................................................................................................3
2. ..........................................................................................4
2.1 ...................................................................4
2.2 ..............................................................5
2.3 ................6
2.4 ...........................................................................9
2.4.1 .......................................................................9
2.4.2 ..............................10
2.4.3 ...................................................................12
2.5 ....................................................................................16
2.5.1 ...............................................................................16
2.5.2 .................................................................................19
2.6 ............................................................................21
2.7 .........................................................................22
3. .................................................................................26
3.1 .........................................................................27
3.1.1 .....................................................................27
3.1.2 ..............................28
3.1.3 ...................................................................31
3.4 ....................................................................................34
3.4.1 ...............................................................................34
3.4.2 .................................................................................36
3.5 ............................................................................38
3.6 .........................................................................40
4. ...................................................................................................44

,

.

.
.
,
.
ANSI - Flowchart Symbols.

.

.
, ,
,
.

(
), .


.
:

, ..

, ..
, ..
, ..
3




.
, , .
,
.

,
.

:
1. (Sequence)
2. H (Selection) ,
(Case)
3. H (Iteration)

-
-

ANSI Flowchart symbols (Capron, H. L., Perron, J. D., p. 520)


1. .
:
i.


. ,
if-then-else ,
.

ii.

2. .
,
( ,
).
3.
. (,
, .).
4. :
, , , , True False, T F, Yes
No, Y - N.
5.
( ) ,
= :=
6. ,
(

a+b+c
, a b , x 2 , , .),
3


: * , / , MOD, DIV, <=, >=, .
7. ( ,
)
. ,
. :
writeln(A:6:2, B:8, Onoma:8);

8.
:
...

9. .
:

10.

,
. :

Praxis(x,y)

x:
y:

a,b
x

x+ y

Praxis(a,b)
y

y+ 7

a, b

11. ,

, ,
,
. :
Grade: (3 x 4)

1 <= 3

2 <= 4

Grade[1, 2]

1 + 1

2 + 1

12.
. :

Evdomada: ,
Evdomada = 7

Evdomada

Evdomada:


()

Salary

Total

rate * hours

Total + Salary



.
(: = r2 , = 2r, = 3.14)

Pi: ,
Pi = 3.14

Pi:
Pi

aktina

emvado

periferia

aktina

Pi * aktina * aktina

2 * Pi * aktina

embado, periferia

3.14

emvado

periferia

Pi * aktina * aktina

2 * Pi * aktina

embado, periferia

()

Salary > 1000

Ta x

Salary * 0.1

Salary * 0.2

Tax

Tax

Salary > 1000

Salary * 0.2

Tax

..

..

Salary

350
Tax

500

Salary * 0.1

Tax

Tax

Salary * 0.3

501-1000

1001-2500

''

Salary * 0.2

Tax

Salary * 0.4

10



,
:
()

.
0
1
2
3
0
1
2
3

1-6

%
10
8
6
4
12
10
8
6

,

.
.

arxikitimi, mikos, doseis

mikos>=1
mikos <= 6

doseis

doseis

0
ekptosi

0.12
ekptosi

ekptosi
0.1

kostos

0.08
ekptosi

0
ekptosi

0.06

0.1
ekptosi

ekptosi
0.08

0.06
ekptosi

0.04

arxikitimi - (arxikitimi * ekptosi)

kostos

11

()

<=

<= 5

Sum

Sum + M

Salary

Salary <
5000

Salary

Salary * 2

Salary

Total

350

M+ 1

Total + Salary

Total > 5000

12


1. 10
2%.
15 .

plithismos

10000000

<= 15

plithismos

plithismos

plithismos + plithismos * 0.02

M+ 1

13

2.

. .

athrisma

plithos

arithmos

athrisma

arithmos
<> -999

athrisma + arithmos

plithos <> 0
plithos
'
'

mesos

plithos + 1

arithmos

athrisma / plithos

athrisma, mesos

14

3.
.

2000 . 1
.

sum

time

time

sum

2 *p

time + 1

sum + p

sum > 2000

time

15

-
...

(1, 2,...)

(1, 2,...)

...

...

(1, 2,...)

(1, 2,...)

...
(, ,...)

16

Praxis(x,y)
a,b

Praxis(a,b)

Result

x+ y

y+ 7

Praxis(a,b)
Praxis

x+ y

Result, a, b

17


(!) (factorial)
0 . ,
5 (5!) 1*2*3*4*5 = 120.
(0! = 1).

0 7 .
.

. .

N < 0
OR
N > 7

' .
'

fact(N)

factorial

fact(N)

N, factorial

fact(P)

m <= p
fact

S* i

i+ 1

18

-
...

(1, 2,...)

...
(, ,...)

:
:

Praxis(x,y)

x:
y:

a,b
x

x+ y

Praxis(a,b)
y
a, b

y+ 7

x, y

19


:
)
.
) ,

)

getdata(onoma, b1, b2, b3)

onoma, b1, b2, b3:


..

onoma, b1, b2, b3

getdata
(name, v1, v2, v3)

mesos(b1, b2, b3, avg)

mesos
(v1, v2, v3, mo)

ektiposi
(name, mo)

b1, b2, b3: ..


avg: ..
avg

(b1+b2+b3)/3

ektiposi(onoma, avg)

onoma, avg: ..
onoma, avg

20


()
: ()
.. Name: (10)

<=

[]

Name: (10)

<= 10

Name[M]

M+ 1

21

()
: (1 x 2)
.. Grade: (3 x 4)

1 <=
1

2 <=
2

1
[1, 2]
A
2

22

Grade: (3 x 4)

1 <= 3

2 <= 4

1 + 1
Grade[1, 2]
A
2

2 + 1

23


,
10 10 .
.
10x10.

A: (10 x 10)
R

R <= 10

min

A[1,1]

1
C <= 10

A[R, C]

R <= 10
C

C + 1

C <= 10

A[R,C]<min
R

R + 1

R + 1
min

A[R,C]

C + 1

24

1
D

R <= 10
C

min

C <= 10

A[R, C]

R + 1

C + 1

25



,
.
.
:
i.

( ).

ii.

iii.

iv.

v.


.
( , )
(, ..
).


(
).

26


()
:
5.5, 8.0
Program Trigono;
Uses Wincrt;
Var
Katheti1, Katheti2, Ypoteinousa,
Perimetros, Emvadon : Real;
Begin
Write(' 1:');
Readln(Katheti1);
Write(' 2:');
Readln(Katheti2);
Ypoteinousa := SQRT(SQR(Katheti1) + SQR(Katheti2));
Perimetros := Katheti1 + Katheti2 + Ypoteinousa ;
Emvadon := Katheti1 * Katheti2 / 2;
Writeln(' 1 :',Katheti1:6:2);
Writeln(' 2 :',Katheti2:6:2);
Writeln(' :',Ypoteinousa:6:2);
Writeln(' :',Perimetros:6:2);
Writeln(' :',Emvadon:6:2)
End.

Katheti1
5.5

Katheti2

Ypoteinousa Perimetros

Emvadon

8.0
9.71

23.21

22.00

1:
2:
1:5.50
2:8.00
:9.71
:23.21
:22.00

27

()
1:
: 2000, 100
Program Rent_A_Car;
Uses Wincrt;
Var
Kivismos : Integer;
Timi, Poso, Ekptosi : Real;
Begin
Ekptosi := 0.0;
Write(' :');
Readln(Kivismos);
Write(' :');
Readln(Timi);
If Kivismos >= 1500 Then
Ekptosi := Timi * 10/100;
Poso := Timi - Ekptosi;
Writeln(' :',Kivismos:5);
Writeln(' :',Timi:6:2);
Writeln(' :',Ekptosi:6:2);
Writeln(' :',Poso:6:2)
End.

Ekptosi
0.0

Kivismos
Timi
2000

10.0

Poso Kivismos>=1500

100

2000>=1500
90.0

:
:
:2000
:100.00
:10.00
:90.00

28

2:
1: M, 45 2: F, 28 .
Program Insurance;
Uses Wincrt;
Var
Age, Asfalistra : Integer;
Sex : Char;
Begin
Write(' :');
Readln(Sex);
Write(' :');
Readln(Age);
If Sex = 'M' Then
If Age < 25 Then
Asfalistra := 300
Else
Asfalistra := 250
Else
If Age < 21 Then Asfalistra := 200
Else Asfalistra := 150;
Writeln(' :',Asfalistra:4)
End.
1
Age

Asfalistra
Sex

Sex=M

/ Age<25

45
250

45<25

/ Age<21

:
:
:250

2
Age

Asfalistra
Sex
F

Sex=M

28
150

F=

28<21

:
:
:150

29


:
aria, 4 .
Program Eniaio;
Uses Wincrt;
Var
Name : String;
Code : Integer;
Begin
Write(' :');
Readln(Name);
Write(' :');
Readln(Code);
Case Code OF
1: Writeln('');
2: Writeln(');
3: Writeln('');
4: Writeln('');
5: Writeln('');
6: Writeln('')
Else
Writeln(' ')
End
End.

Name Code
Maria
4

Code (/)
3 4 5
6

:
:

30

()
1: .

Program Average;
Uses Wincrt;
Var
No, Sum, Metritis : Integer;
Mesos : Real;
Begin
Sum := 0;
Metritis := 0;
For No := 10 To 15 Do
Begin
Sum := Sum + No;
Metritis := Metritis + 1
End;
Mesos := Sum / Metritis;
Writeln(' :',Mesos:6:2)
End.

o
10
11
12
13
14
15

Sum Metritis
0
0
10
1
21
2
33
3
46
4
60
5
75
6

Mesos

No<=15 /
10<=15

11<=15
12<=15
13<=15
14<=15
15<=15

:12.50

12.5

31

2: .
Program Sum_Of_Odd_Nos;
Uses Wincrt;
Var
Arithmos, Sum : Integer;
Begin
Sum := 0;
Arithmos := 1;
While Arithmos <= 11 Do
Begin
Sum := Sum + Arithmos;
Arithmos := Arithmos + 2
End;
Writeln(' (1-11) :',Sum:5)
End.

Arithmos Sum
1
0
1
3
4
5
9
7
16
9
25
11
36
13

Arithmos<=11 /
1<=11

3<=11
5<=11
7<=11
9<=11
11<=11
13<=11

(1-11) :36

32

3: .
Program Sum_Of_Odd_Nos;
Uses Wincrt;
Var
Arithmos, Sum : Integer;
Begin
Sum := 0;
Arithmos := 1;
Repeat
Sum := Sum + Arithmos;
Arithmos := Arithmos + 2
Until Arithmos > 11;
Writeln(' (1-11) :',Sum:5)
End.

Arithmos Sum
1
0
3
1
5
4
7
9
9
16
11
25
13
36

Arithmos>11
/
3>11
5>11
7>11
9>11
11>11
13>11

(1-11) :36

33

-
1:
: 10.5, 12.5 .
Program Demo1;
Uses Wincrt;
Var
Mikos, Platos, Perim :Real;
Function Calculate (M, P:Real):Real;
Var
Emvadon, Perimetros:Real;
Begin
Emvadon := P * M;
Perimetros := 2.0 * (M + P);
Writeln('T :',Emvadon:8:2);
Calculate := Perimetros
End;
Begin { }
Write(' :');
Readln(Mikos);
Write(' :');
Readln(Platos);
Perim := Calculate(Mikos, Platos);
Writeln('H :',Perim:8:2)
End.

Mikos
10.5

Platos
Perim
12.5
46

:
:
: 131.25
: 46.00

Function Calculate

M
P
10.5
12.5


Emvadon
Perimetros
131.25
46

Calculate
46

34

2:
: 5, 10 .
Program Megaliteros;
Uses Wincrt;
Var
Arithmos1, Arithmos2 :Integer;
Function Bigger(Num1, Num2 :Integer):Integer;
Begin
If Num1 > Num2 Then
Bigger := Num1
Else
Bigger := Num2
End;
Begin{ }
Write(' :);
Readln(Arithmos1, Arithmos2);
Writeln(' :', Bigger(Arithmos1, Arithmos2):6)
End.

Arithmos1
5

Arithmos2
10

:
:10

Function Bigger

Num1
Num2
5
10

Num1>Num2
5>10

Bigger
10

35


1:
:10, 12, 3.
Program Vol_Per;
Uses Wincrt;
Var
Len, Wid, Heit :Integer;
Procedure Perivol(Length,Width,Height:Integer);
Var
Perimeter, Volume:Integer;
Begin
Perimeter := Length + 2 * Width * Height;
Volume := Length * Width * Height;
Writeln(' :',Perimeter:6);
Writeln(' :',Volume:6)
End;
Begin { }
Write(' :');
Readln(Len);
Write(' :');
Readln(Wid);
Write(' :');
Readln(Heit);
Perivol(Len,Wid,Heit)
End.

Len Wid
Heit
10
12
3

:
:
:
: 82
: 360

Procedure Perivol

Length
Width
Height
10
12
3

o
Perimeter
Volume
82
360

36

2:
:10, 12, 3.
Program Vol_Per;
Uses Wincrt;
Var
Len, Wid, Heit :Integer;
Perim, Vol : Integer;
Procedure Perivol(Length,Width,Height:Integer;Var Perimeter, Volume:Integer);
Var
Begin
Perimeter := Length + 2 * Width * Height;
Volume := Length * Width * Height
End;
Begin { }
Write(' :');
Readln(Len);
Write(' :');
Readln(Wid);
Write(' :');
Readln(Heit);
Perivol(Len,Wid,Heit, Perim, Vol);
Writeln(' :',Perim:6);
Writeln(' :',Vol:6)
End.

Len
10

Wid
12

Heit Perim
3
82

Vol
360

:
:
:
: 82
: 360

Procedure Perivol

Length
Width
Height
10
12
3


Perimeter
Volume
82
360

37


1:
: 10, 20, 30, 40, 50 .
Program Pinakes;
Uses Wincrt;
Const
Low=1; High=5;
Type
List = Array[Low..High] of Integer;
Var
Lista : List;
I : Integer;
Begin
For I := Low to High Do
Begin
Write(' :');
Readln(Lista[I])
End;
Writeln(' :');
For I := High Downto Low Do
Writeln(Lista[I]:5)
End.

Low High
1

Lista

I<=5

I>=1

10

1<=5

20

2<=5

30

3<=5

40

4<=5

50

5<=5

5>=1

4>=1

3>=1

2>=1

20

1>=1

10

:
50
40
30

38

2: .
Program Pinakes2;
uses wincrt;
Type
pin = array[1..6] of integer;
Var
a:pin;
i:integer;
Begin
For i := 1 to 5 do
a[i] := i * 3;
For i := 1 to 4 do
a[i+1] := i * a[i];
For i := 1 to 5 do
writeln(a[i]:5)
End.

i
1
2
3
4
5
1
2
3
4
1
2
3
4
5

a

1
3
2
6
3
9
4
12
5
15
2
3
3
6
4
18
5
72
1
2
3
4
5

i <=5

i<=4 i<=5

1<=5
2<=5
3<=5
4<=5
5<=5
1<=4
2<=4
3<=4
4<=4
1<=5
2<=5
3<=5
4<=5
5<=5

/
A
A
A
A
A
A
A
A
A
A
A
A
A
A

3
3
6
18
72

39


1:
:3, 2, -1, 0, 6, 8, 11, 2, 10.
Program Pinakes_Dis;
Uses Wincrt;
Const
Max = 3;
Type
Pin = Array[1..Max,1..Max] of Integer;
Var
A : Pin;
I,J,Sum : Integer;
Begin
Writeln(' :');
For I := 1 to Max Do
For J := 1 to Max Do
Readln(A[I,J]);
Sum := 0;
For I := 1 to Max Do
For J := 1 to Max Do
If I = J Then
Sum := Sum + A[I,J];
Writeln(' :',Sum:6)
End.

40


Max

Sum

I
1

I =J

I<=Max

J<=Max

1<=3

1<=3

:
:19

1,1

1,2

2<=3

1,3

-1

3<=3

2,1

1<=3

2,2

2<=3

2,3

3<=3

3,1

11

1<=3

3,2

2<=3

3,3

10

3<=3

1,1

1<=3

1=1

1,2

2<=3

1=2

1,3

3<=3

1=3

2,1

1<=3

2=1

2,2

2<=3

2=2

2,3

3<=3

2=3

3,1

1<=3

3=1

3,2

2<=3

3=2

3,3

3<=3

3=3

2<=3

3<=3

0
3

2
9
3
19

1<=3

2<=3

3<=3

41

2:
:3, 2, -1, 0, 6, 8, 11, 2, 10.
Program Pinakes_Dis_1;
Uses Wincrt;
Const Max = 3;
Type
Pin = Array[1..Max,1..Max] of Integer;
Var
A : Pin; I,J,Sum : Integer;
Procedure Isodos(Var P:Pin);
Begin
Writeln(' :');
For I := 1 to Max Do
For J := 1 to Max Do
Readln(P[I,J])
End;
Function Calculate(P:Pin):Integer;
Var
Total : Integer;
Begin
Total := 0;
For I := 1 to Max Do
For J := 1 to Max Do
If I = J Then Total := Total + P[I,J];
Calculate := Total
End;
Begin { }
Isodos(A); Sum := Calculate(A);
Writeln(' :',Sum:6)
End.

42


Max

Sum

19

A

1,1
3
1,2
2
1,3
-1
2,1
0
2,2
6
2,3
8
3,1
11
3,2
2
3,3
10
1,1
3

:
:19

Procedure Isodos

I
J
1
2
3

1,1
3
1,2
2
1,3
-1
2,1
0
2,2
6
2,3
8
3,1
11
3,2
2
3,3
10

1
2
3
1
2
3
1
2
3

I<=Max

1<=3

2<=3

3<=3

J<=Max
1<=3
2<=3
3<=3
1<=3
2<=3
3<=3
1<=3
2<=3
3<=3

/
A
A
A
A
A
A
A
A
A

Function Calculate


Total
I
J
0
3

1
2

9
3
19

1
2
3
1
2
3
1
2
3


P

1,1
1,2
1,3
2,1
2,2
2,3
3,1
3,2
3,3

3
2
-1
0
6
8
11
2
10

I<=Max

J<=Max

I=J

1<=3

2<=3

3<=3

1<=3
2<=3
3<=3
1<=3
2<=3
3<=3
1<=3
2<=3
3<=3

A
A
A
A
A
A
A
A
A

1=1
1=2
1=3
2=1
2=2
2=3
3=1
3=2
3=3

:
.

43

1.


, , ,
. .
1999.
2.

.
, , ,
. .
1999.
3.

.
, , ,
. .
1999.
4. Visual Basic.

2 .
, , , .
, .
5. Computer programming in the Pascal Language. By Neal Golden, Antonio M.
Lopez, Jr. Harcourt Brace Jovanovich, Publishers.
6. Pascal The software fundamentals of computer science.
By Richard A, Meyers. Prentice-Hall International Editions.
7. Software Engineering. A Practitioners Approach .Third Edition. By
Roger S. Pressman. McGraw Hill International Edition 1992.
8. Computing: An Introduction to Procedures and Procedure Followers. By Fred
M. Tonge and Julian Feldman. McGraw-Hill Book Company.
9. Computers and Information Systems. Third edition. By H. L Capron and John
D. Perron. The Benjamin / Cummings Publishing Company, Inc.
10. FORTRAN a structured, disciplined style . By Gordon B. Davis, Thomas
R. Hoffmann. McGraw Hill Company.
11. Computer programming in the Basic Language. Third Edition.
By Neal Golden. Harcourt Brace Jovanovich, Publishers.
44

12. Computer programming in the Basic Language. Teachers manual and


resource guide. Third Edition. By Neal Golden. Harcourt Brace
Jovanovich, Publishers.
13. Basic for students using the IBM PC. Second edition By Michael
Trombetta. Addison Wesley Publishing Company.
14. Microsoft Basic using Modular Structure. Third Edition. By: Julia Case
Bradley. WCB 1991.
15. Structured VAX Basic and Basic-Plus. Second Edition. By: Teglovic Jr.
and Kenneth D. Douglas. IRWIN-1987.
16. Understanding Computer Science for Advanced Level. Fourth Edition. By: R.
Bradley. Stanley Thornes Publishers Ltd 1999.

45

You might also like