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 Greater
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> words = new List<string>();
- words.Add("hi");
- words.Add("from");
- words.Add("from");
- words.Add("this");
- words.Add("world");
- Console.WriteLine(checkGreater(words, "world"));
- Console.ReadLine();
- }
- public static int checkGreater(List<string> a, string s)
- {
- int i = 0;
- int count = 0;
- int positionalValue = 0;
- List<string> afterWords = new List<string>();
- foreach (string word in a)
- {
- if (word == s)
- {
- if (count == 0)
- {
- positionalValue = i;
- count++;
- }
- }
- if (positionalValue != 0 && i > positionalValue)
- {
- if (word != s)
- {
- afterWords.Add(word);
- }
- }
- i++;
- }
- return afterWords.Count();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement