Предмет: Информатика,
автор: Tangetsu
Дан одномерный массив, выведите на экран элементы массива, делящиеся на число P без остатка, 50 баллов
Ответы
Автор ответа:
1
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] + " ");
}
}
}
}
Похожие вопросы
Предмет: Математика,
автор: Iheaterussia
Предмет: Литература,
автор: kiteedash
Предмет: Биология,
автор: albinxq0
Предмет: Математика,
автор: GhfGoob
Предмет: Литература,
автор: Аноним