cats #535(2007/07/11 07:17 GMT) [ C# ] Rating0/0=0.00
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(); } }
Rating0/0=0.00-0+
[ reply ]
cats #535() [ C# ] Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]