HY 100 : ΕΙΣΑΓΩΓΗ ΣΤΗΝ ΕΠΙΣΤΗΜΗ ΥΠΟΛΟΓΙΣΤΩΝ

  • View
    69

  • Download
    0

Embed Size (px)

DESCRIPTION

, , . HY 100 : . , . . 4. . - PowerPoint PPT Presentation

Transcript

  • HY100 : , , ,

  • 4

  • (1/3) : (1) ,

  • (2/3) : . :

  • (3/3) , runtime error . , runtime error .

    REAL x;INPUT(x);INPUT(POSITION(0,0));IF x >= 0 THENOUTPUT(x);ELSEOUTPUT(x);IF POSITION(0,0) >= 0 THENOUTPUT(POSITION(0,0));ELSEOUTPUT(-POSITION(0,0));

  • (1/4) = ; ( ) ( )x, y, P[9], arxh.x, telos.y (x+y)/2 * (arxh.x telos.x)/2 x = GETINPUT;P[3] = GETINPUT;

  • (2/4) GETINPUT GETINPUT : . , GETINPUT, (undefined): , , GETINPUT .. x = GETINPUT; 42 , , GETINPUT 42, x=42;

  • - GETINPUTinput output ( 2005)

  • (3/4)

    RECORD Point RECBEGIN INTEGER x,y; RECEND;Point first, last;INTEGER a, b; first.x = GETINPUT;first.y = GETINPUT;last.x = GETINPUT;last.y = GETINPUT;a = last.x - first.x;b = last.y first.y; . .

  • (4/4)a = last.x first.x ( (last.x), (last.x) ) ( (first.x), (first.x) ) ( (x), (x) ) :1. (READ)2. (READ)3. (SUB)4. (WRITE)

  • x y. , . x=5 y=8 x=8 y=5.

    1. ! 2. temp ! 3. 4.

    INTEGER x, y;PROGRAM_BEGININPUT(x); INPUT(y);OUTPUT(x); OUTPUT(y);/* (-) ? */ OUTPUT(x); OUTPUT(y);PROGRAM_END

    INTEGER temp;

    temp = x;

    x = y;

    y = temp;

  • (1/8) + * / - - * / + - x * y + z / w * -k :(x * y) + (( z / w) * (-k)) , . (((x * y) + z) / w) * (-k) , .

  • (2/8)x * y + z / w * -k xyzwk(x*y) (z/w) (-k) ((z/w) * (-k)) (x*y) + ((z/w) * (-k)) ,

  • (3/8) ? , . . , ... x+y+z (x+y) + z x + (y+z). . .

  • (4/8)a = (x1-y1) * (x2-y2) + (x3-y3) 1 2 3 4 5

    (x1-y1)

    (x1-y1)(x2-y2)

    (x1-y1)*(x2-y2)(x2-y2)

    (x1-y1)*(x2-y2)(x3-y3)

    (x3-y3)

  • (5/8) , INTEGER REAL, :, sqr(x) .. z = sqr(x+y) : x y, , sqr, , z. , sqrt(x), sin(), , cos(), , tan(),

  • (6/8) (1/3) , : = cos() * = sin() * ?

  • (7/8) (2/3) (scientific computation problems)

    REAL A, B, C, phi;1. INPUT(phi);INPUT(C);2. A = cos(phi) * C;B = sin(phi) * C;3. OUTPUT(A);OUTPUT(B);4.

  • (8/8) (3/3)=120=60 = 1046030=78=67.5 = 396030=112=79.2 = 79.24545 .

  • (1/6) (true) (false). : . strings ( ):> >= <
  • (2/6)

    INTEGER x,y;PROGRAM_BEGININPUT(x);INPUT(y);OUTPUT(x > y);PROGRAM_END

    INTEGER x,y;BOOLEAN b;PROGRAM_BEGININPUT(x);INPUT(y);b = x > y;OUTPUT(b);PROGRAM_END

  • (3/6) string x, y, z

    STRING a,b;PROGRAM_BEGININPUT(a);INPUT(b);OUTPUT(a > b);PROGRAM_END

    INTEGER x,y,z;PROGRAM_BEGININPUT(x); INPUT(y); INPUT(z);OUTPUT((x+y) EQUAL (y+z) OR x DIFFERENT z);PROGRAM_END

  • (4/6) OR, AND NOT ,

    AND, 1 2TRUETRUETRUETRUEFALSEFALSEFALSETRUEFALSEFALSEFALSEFALSE

    OR, 1 2TRUETRUETRUETRUEFALSETRUEFALSETRUETRUEFALSEFALSEFALSE

    NOT, TRUEFALSEFALSETRUE

    NOTANDOR

  • (5/6) x >=y AND z < w OR NOT b 1 2xy>=zw= y)

    (x >= y)(z < w)

    (x>=y) AND (x

  • (6/6) , , , . .

    ( )

    BOOLEAN b;PROGRAM_BEGININPUT(b);OUTPUT(b AND NOT b);OUTPUT(b OR NOT b);PROGRAM_END

  • , ., , . , , , .

  • (1/5) , : 1 2IF THEN 1 ELSE 2 , : , 1 (), ELSE 2 ELSE IF block.

  • (2/5)

    REAL x;PROGRAM_BEGININPUT(x);IF x < 0 THENOUTPUT("Square root of negative number!");ELSEOUTPUT(sqrt(x));PROGRAM_END

  • (3/5) IFTHENELSE , 1 2 . , .abc a=b b=c a=b b=c a=c 1 2,

  • (4/5) !!

    REAL a,b,c;PROGRAM_BEGININPUT(a); INPUT(b); INPUT(c);IF a EQUAL b AND b EQUAL c THENOUTPUT("ISOPLEURO");ELSEIF a EQUAL b OR a EQUAL c OR b EQUAL c THENOUTPUT("ISOSKELES");ELSEOUTPUT("SKALHNO");PROGRAM_END

  • (5/5), .

    REAL x;PROGRAM_BEGININPUT(x);IF x < 0 THEN IF x < -1000 THEN OUTPUT("x in (-a, -1000)"); ELSE OUTPUT("x in [-1000, 0)");ELSE IF x < 1000 THEN OUTPUT("x in [0, 1000)"); ELSE OUTPUT("x in [1000, +a)");PROGRAM_END