Advertisement
fbinnzhivko

7.00 To Uppercase

Jun 4th, 2016
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2. class ParseTags
  3. {
  4.     static void Main()
  5.     {
  6.         string text = Console.ReadLine();
  7.         string modified = string.Empty;
  8.         for (int i = 0; i < text.Length; i++)
  9.         {
  10.             string openTag = "<upcase>";
  11.             string closeTag = "</upcase>";
  12.  
  13.             int indexOpen = text.IndexOf(openTag, i);
  14.             int indexClose = text.IndexOf(closeTag, i);
  15.             if (i == indexOpen)
  16.             {
  17.                 if (indexOpen != -1 && indexClose != -1)
  18.                 {
  19.                     for (int j = indexOpen + openTag.Length; j < indexClose; j++)
  20.                     {
  21.                         modified += text[j].ToString().ToUpper();
  22.                     }
  23.                     i += indexClose - indexOpen + closeTag.Length;
  24.                 }
  25.             }
  26.             if (i < text.Length)
  27.             {
  28.                 modified += text[i];
  29.             }
  30.         }
  31.         Console.WriteLine(modified);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement