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;
- namespace ConsoleApplication1
- {
- class Program
- {
- static int Counter(string st)
- {
- int counter = 0;
- st = st.ToLower();
- while (st.IndexOf(" ") != -1)
- {
- int x = st.IndexOf(" ");
- if (st[x - 1] == st[x + 1])
- counter++;
- st = st.Remove(x, 1);
- }
- Console.WriteLine(st);
- return counter;
- }
- static void Main(string[] args)
- {
- string st = "Hello obama ate eat turtles";
- Console.Write(Counter(st));
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment