Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ListsAndMatrices
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- List<int> possitiveNumbers = new List<int>();
- OnlyPossitiveList(numbers,possitiveNumbers);
- possitiveNumbers.Reverse();
- PrintList(possitiveNumbers);
- }
- public static void OnlyPossitiveList(List<int> list,List<int> resultList)
- {
- foreach (var item in list)
- {
- if (item>=0)
- {
- resultList.Add(item);
- }
- }
- }
- public static void PrintList(List<int> list)
- {
- foreach (var item in list)
- {
- Console.WriteLine(item);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment