Вопрос задан 17.02.2019 в 14:00. Предмет Информатика. Спрашивает Бойко Максим.

1. Дан одномерный массив размерностью 10, заполненный целыми числами, введенными с клавиатуры, и

величина N. Отрицательные элементы заменить на N. Измененный массив вывести на экран одной строкой. 2. Дан одномерный массив размерностью N, заполненный случайными числами в интервале от -15 до 20. Вывести на экран значения элементов массива, абсолютное значение которых >10. 3. Дан одномерный массив размерностью N, заполненный случайными числами. Каждый третий элемент массива возвести в квадрат, если элемент отрицательный. Измененный массив вывести на экран.
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Пойдун София.
1)    var
 a:array[1..10]of integer;
 i,n,k:integer;
  begin
   readln(n);
    for i:=1 to 10 do
     begin
      read(a[i]);
      if a[i]< 0 then
      a[i]:=n;
     end;
     for i:=1 to 10 do
      write(a[i],' ');
     end.

2)

var
 a:array[1..999999]of integer;
 i,n,s:integer;
   begin
     readln(n);
     for i:=1 to n do
      begin
       a[i]:=random(36)-15;
       write(a[i],' ');
      end;
      writeln;
      for i:=1 to n do
       if abs(a[i])>10 then
       write(a[i],' ');
     end.


3)

     var
 a:array[1..999999]of integer;
 i,n,s:integer;
   begin
     readln(n);
     for i:=1 to n do
      begin
       a[i]:=random(36)-15;
       write(a[i],' ');
      end;
      writeln;
      for i:=1 to n do
       begin
        if i mod 3 = 0 then
         if a[i]<0 then
         a[i]:= a[i]*a[i]*a[i];
        write(a[i],' ');
        end;
      end.


0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

I can help you with some programming tasks. Here are the detailed answers to your questions:

1. To solve this problem, you need to use a loop to iterate over the array and check each element. If the element is negative, you need to replace it with N. Then you can use a print function to display the modified array on the screen. Here is an example of how to do this in Python:

```python # Input the array elements array = [] for i in range(10): array.append(int(input("Enter an integer: ")))

# Input the value of N N = int(input("Enter the value of N: "))

# Replace negative elements with N for i in range(10): if array[i] < 0: array[i] = N

# Print the modified array print(array) ```

2. To solve this problem, you need to use a random module to generate the array elements and a loop to iterate over them. You also need to use an absolute value function to compare the elements with 10. Then you can use a print function to display the elements that meet the condition. Here is an example of how to do this in Python:

```python # Import the random module import random

# Input the size of the array N = int(input("Enter the size of the array: "))

# Generate the array elements array = [] for i in range(N): array.append(random.randint(-15, 20))

# Print the elements that have absolute value greater than 10 for i in range(N): if abs(array[i]) > 10: print(array[i]) ```

3. To solve this problem, you need to use a random module to generate the array elements and a loop to iterate over them. You also need to use a modulo operator to find every third element and a power operator to square it. Then you can use a print function to display the modified array. Here is an example of how to do this in Python:

```python # Import the random module import random

# Input the size of the array N = int(input("Enter the size of the array: "))

# Generate the array elements array = [] for i in range(N): array.append(random.randint(-10, 10))

# Square every third negative element for i in range(N): if i % 3 == 0 and array[i] < 0: array[i] = array[i] ** 2

# Print the modified array print(array) ```

0 0

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос