Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Task3
- {
- public class Program
- {
- static void Main(string[] args)
- {
- int[] inputArray = { 1, 5, 8, 3, 10 };
- int threshold = 5;
- int[] filtered = FilterGreaterThan(inputArray, threshold);
- Console.WriteLine($"Элементы больше {threshold}: {string.Join(", ", filtered)}");
- }
- public static int[] FilterGreaterThan(int[] arr, int threshold)
- {
- List<int> result = new List<int>();
- foreach (int num in arr)
- {
- if (num > threshold)
- {
- result.Add(num);
- }
- }
- return result.ToArray();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement