Add tags

Add tags to the following comment
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Text;
class Program
{
  static void Main(string[] args)
  {
    Console.WriteLine(RemoveBlockComment("AAA"));
    Console.WriteLine(RemoveBlockComment("AAA/*/BBB"));
    Console.WriteLine(RemoveBlockComment("AAA/*BBB"));
    Console.WriteLine(RemoveBlockComment("AAA/*BBB*/CCC"));
    Console.WriteLine(RemoveBlockComment("AAA/*BBB/*CCC*/DDD*/EEE"));
    Console.WriteLine(RemoveBlockComment("AAA/a//*BB*B**/CCC"));
  }

  static string RemoveBlockComment(string s)
  {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < s.Length; ++i)
    {
      if (i < s.Length - 1 && s[i] == '/' && s[i + 1] == '*')
      {
        i += 3;
        while (i < s.Length && (s[i - 1] != '*' || s[i] != '/')) ++i;
      }
      else sb.Append(s[i]);
    }
    return sb.ToString();
  }
}

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...