Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace SoftUniLists
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Enter your numbers here: ");
- List<int> numbers = ReadList();
- foreach(int number in numbers)
- {
- if(number < 0)
- {
- numbers.Remove(number);
- }
- }
- if(numbers.Count == 0)
- {
- Console.WriteLine("Empty");
- }
- else
- {
- for(int i = numbers.Count - 1; i >= 0; i--)
- {
- Console.Write(numbers[i] + " ");
- }
- }
- }
- static List<int> ReadList(int n)
- {
- var list = new List<int>();
- for (int i = 0; i < n; i++)
- {
- list.Add(int.Parse(Console.ReadLine()));
- }
- return list;
- }
- static List<int> ReadList()
- {
- List<int> list = new List<int>();
- var line = Console.ReadLine();
- list = line.Split().Select(int.Parse).ToList();
- return list;
- }
- static void PrintList(List<int> list)
- {
- for (int i = 0; i < list.Count; i++)
- {
- Console.WriteLine(list[i]);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment