Advertisement
smc_gamer

PP in C#

Nov 25th, 2011
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. public bool CheckPP(string post)
  2. {
  3.     List<int> start_parens;
  4.     List<int> end_parens;
  5.     int i;
  6.  
  7.     foreach (Char c in post)
  8.     {
  9.         if (c == '(')
  10.         {
  11.             // Start parentheses.
  12.             start_parens.Add(i);
  13.         }
  14.         elseif (c == ')')
  15.         {
  16.             // End parentheses.
  17.             end_parens.Add(i);
  18.         }
  19.         i++
  20.     }
  21.  
  22.     i = 0;
  23.     int length; // The length of text in parens.
  24.     foreach (int l in start_parens)
  25.     {
  26.         length += (end_parens[i] - start_parens[i]);
  27.         i++
  28.     }
  29.     if length >= (post.Length / 2) { return true; }
  30.     return false;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement