Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- namespace _07.ToUppercase
- {
- class ToUppercase
- {
- static void Main()
- {
- int bufSize = 1024;
- Stream inStream = Console.OpenStandardInput(bufSize);
- Console.SetIn(new StreamReader(inStream, Console.InputEncoding, false, bufSize));
- string text = Console.ReadLine();
- string startUpcase = "<upcase>";
- string endUpcase = "</upcase>";
- int startIndex = 0;
- int endIndex = 0;
- string result = string.Empty;
- while (startIndex != -1 && endIndex != -1)
- {
- startIndex = text.IndexOf(startUpcase);
- endIndex = text.IndexOf(endUpcase);
- if (startIndex != -1 && endIndex != -1)
- {
- var replaceText = text.Substring(startIndex + startUpcase.Length, endIndex - startIndex - endUpcase.Length + 1);
- var modifiers = replaceText.ToUpper();
- result = text.Replace(replaceText, modifiers);
- result = result.Remove(startIndex, startUpcase.Length);
- result = result.Remove(startIndex + modifiers.Length, endUpcase.Length);
- text = result;
- }
- }
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement