MuffinMonster

Class Task 58#

Mar 13th, 2014
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static int Counter(string st)
  11.         {
  12.             int counter = 0;
  13.             st = st.ToLower();
  14.             while (st.IndexOf(" ") != -1)
  15.             {
  16.                 int x = st.IndexOf(" ");
  17.                 if (st[x - 1] == st[x + 1])
  18.                     counter++;
  19.                 st = st.Remove(x, 1);
  20.             }
  21.             Console.WriteLine(st);
  22.             return counter;
  23.         }
  24.         static void Main(string[] args)
  25.         {
  26.             string st = "Hello obama ate eat turtles";
  27.             Console.Write(Counter(st));
  28.             Console.ReadKey();
  29.  
  30.         }
  31.     }
  32. }
Add Comment
Please, Sign In to add comment