Book of tasks on programming. Old version

 

 by Aliaksandr N. Prykhodzka

 

array, сети Петри, counter, университет, pascal, абстрактный, реализация, text, open, off-line, константа, десятичный, параметр, floppy, метод, logical
 

for valuable work you must have JavaScript (allow active content)

Java. J.18. Nest of tasks. Tasks on substitution of operators

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.18.1     Answer      Pascal-analogue      Visual Basic-analogue

Put operators (as y:=y+ ... or y:=y- ...) into empty places to program write the given number. You may use operator as "y:=number" at extreme case (for example, if it is the first operator of program).


int AA()    // 40
{
    int s=0;
    for (int i=1; i<6; i++) _________;
    return s;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.18.2     Answer      Pascal-analogue      Visual Basic-analogue

Put operators (as y:=y+ ... or y:=y- ...) into empty places to program write the given number. You may use operator as "y:=number" at extreme case (for example, if it is the first operator of program).


int AA()    // 21
{
    int s=0;
    for (int i=1; i<6; i++)
        if (i % 2 == 0) ______;
        else ______;
    return s;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.18.3     Answer      Pascal-analogue      Visual Basic-analogue

Put operators (as y:=y+ ... or y:=y- ...) into empty places to program write the given number. You may use operator as "y:=number" at extreme case (for example, if it is the first operator of program).


int AA()    // 18
{
    int s=0;
    for (int i=1; i<6; i++)
        if (i % 3 > 0) _______;
        else ________;
    return s;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.18.4     Answer      Pascal-analogue      Visual Basic-analogue

Put operators (as y:=y+ ... or y:=y- ...) into empty places to program write the given number. You may use operator as "y:=number" at extreme case (for example, if it is the first operator of program).


int AA()    // 30
{
    int s=0;
    for (int i=1; i<4; i++)
        for (int j=1; j     return s;
}

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.18.5     Answer      Pascal-analogue      Visual Basic-analogue

Put operators (as y:=y+ ... or y:=y- ...) into empty places to program write the given number. You may use operator as "y:=number" at extreme case (for example, if it is the first operator of program).


int AA()    // 53
{
    int s;
    int[] A = new int[5];
    for (int i=1; i<5; i++) _______;
    s=0;
    for (int i=1; i<4; i++) s=s+A[i]*A[i+1];
    return s;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.18.6     Answer      Pascal-analogue      Visual Basic-analogue

Put operators (as y:=y+ ... or y:=y- ...) into empty places to program write the given number. You may use operator as "y:=number" at extreme case (for example, if it is the first operator of program).


int AA()      // 90
{
      int s=0;
      for (int i=1; i<4; i++) _______;
      int k=0;
      for (int j=1; j<5; j++) _______;
      s=s*k;
      return s;
}



 

©   Aliaksandr Prykhodzka    1993 - 2007