Дан одномерный массив, выведите на экран элементы массива, делящиеся на число P без остатка, 50 баллов
Ответы на вопрос
C#
using System;
class MainClass {
public static void Main (string[] args) {
int[] array;
int p;
Console.WriteLine("Enter the number of elements in the array: ");
int n = Convert.ToInt32(Console.ReadLine());
array = new int[n];
Console.WriteLine("Enter the elements of the array: ");
for (int i = 0; i < n; i++) {
array[i] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("Enter the number P: ");
p = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Elements of the array that are divisible by " + p + " without a remainder:");
for (int i = 0; i < n; i++) {
if (array[i] % p == 0) {
Console.Write(array[i] + " ");
}
}
}
}