Есть ответ 👍

Сколько раз выполнится тело цикла? 1)for x: =3 to 8 do write ( '*' ); 2)for x: =1 to 1 do write ( '*' ); 3)for x: =5 to 3 do write ( '*' ); 4)for x: =7 downto 4 do write ( '*' ); 5)for x: =2 downto 2 do write ( '*' ); 6)for x: =4 downto 9 do write ( '*' );

110
276
Посмотреть ответы 2

Ответы на вопрос:


1) x=3, 4, 5, 6, 7, 8 - 6 раз (8-3+1 = 6) 2) 1 раз 3) 0 раз (в цикле с "to" конечное значение параметра должно быть > = начального значения, а здесь 3< 5) 4) x = 7, 6, 5, 4 - 4 раза 5) 1 раз 6) 0 раз (в цикле с "downto" конечное значение параметра должно быть < = начального значения, а здесь 3< 5)

#include < iostream> #include < ctime> int main() {       using namespace std;       const int size = 25;       int massive[size];       //1й пункт       cout < < "enter number: ";             int num;       cin > > num;       int s = 0;       for (int i = 1; i < = num; i++)             if (num % i == 0)                   if (i % 2 == 1)                         s = s + i;       cout < < "the sum of the odd divisors: " < < s < < endl;       //2й пункт       for (int i = 0; i < size; i++)         {             cout < < "enter #" < < i + 1 < < " element: ";             cin > > massive[i];       }       for (int i = 0; i < size; i++)             if (massive[i] < 0)             {                   massive[i] = 0;                   break;             }       for (int i = 0; i < size; i++)             cout < < massive[i] < < ' ';       //3й пункт       for (int i = 0; i < size; i++)             massive[i] = i + 1;       for (int i = 0; i < size; i++)             if (massive[i] % 3 == 0)                   massive[i] *= massive[2];       cout < < endl;       for (int i = 0; i < size; i++)             cout < < massive[i] < < ' ';       //4й пункт       srand(time(0));       for (int i = 0; i < size; i++)             massive[i] = rand();       cout < < endl;       for (int i = 0; i < size; i++)             cout < < massive[i] < < ' ';       cout < < endl;       cout < < "enter number: ";       int num2;       cin > > num2;       bool ifsum = false;       for (int i = 0; i < size - 1; i++)             if (massive[i] + massive[i + 1] == num2)             {                   ifsum = true;                   break;             }       if (ifsum)             cout < < "yes";       else             cout < < "no";       cout < < endl;       return 0; }

Популярно: Информатика