Bob103

C#_String(III-16)

Oct 27th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. namespace ConsoleApplication1
  5. {
  6.    class Program
  7.     {
  8.         private static void Main()
  9.         {
  10.             string TEXT = Console.ReadLine();
  11.  
  12.             StringBuilder total = new StringBuilder();
  13.             for (int i = 1; i < TEXT.Length; i++)
  14.             {
  15.                 char previousChar = TEXT[i - 1];
  16.                 char followingChar = TEXT[i];
  17.                 if (char.IsPunctuation(previousChar) && char.IsLetterOrDigit(followingChar))
  18.                 {
  19.                     total.Append(previousChar + " ");
  20.                 }
  21.                 else total.Append(previousChar);
  22.  
  23.                /* if ((char.IsLetterOrDigit(previousChar) && char.IsWhiteSpace(followingChar)))
  24.                 {
  25.                     total.Replace(" ", "");
  26.                 }
  27.                */
  28.             }
  29.             total.Append(TEXT[TEXT.Length - 1]);
  30.             string correctText = total.ToString();
  31.             Console.WriteLine(correctText);
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment