Advertisement
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 _10.RemoveNegativesAndReverse
- {
- public class RemoveNegativesAndReverse
- {
- public static void Main(string[] args)
- {
- string inputStr = Console.ReadLine();
- string[] inputArr = inputStr.Split(' ');
- List<int> inputInt = new List<int>();
- List<int> newIntList = new List<int>();
- for (int i = 0; i < inputArr.Length; i++)
- {
- inputInt.Add(int.Parse(inputArr[i]));
- }
- for (int i = 0; i < inputInt.Count; i++)
- {
- if (inputInt[i] > 0)
- {
- newIntList.Add(inputInt[i]);
- }
- }
- if (newIntList.Any())
- {
- newIntList.Reverse();
- foreach (var item in newIntList)
- {
- Console.WriteLine(item);
- }
- }
- else
- {
- Console.WriteLine("empty");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement