Олимпиадный тренинг

Задача . 33736


Задача

Темы:
Consider the following incomplete method.

public int someProcess(int n)
{
    /* body of someProcess */
}
 
The following table shows several examples of input values and the results that should be produced by calling someProcess.
Input Value n Value Returned by someProcess(n)
3 30
6 60
7 7
8 80
9 90
11 11
12 120
14 14
16 160

    Which of the following code segments could be used to replace /* body of someProcess */ so that method will produce the results shown in the table?

1) 
if ((n % 3 == 0) && (n % 4 == 0))
    return n * 10;
else
    return n;

2)
if ((n % 3 == 0) || (n % 4 == 0))
    return n * 10;
return n;

3) 
if (n % 3 == 0)
    if (n % 4 == 0)
        return n * 10;
return n;

A) I only
B) II only
C) III only
D) I and III
E) II and III
 

time 1000 ms
memory 32 Mb
Правила оформления программ и список ошибок при автоматической проверке задач

Статистика успешных решений по компиляторам
Комментарий учителя