//串定位 public int IndexOf(SeqString s, int starpos) { SeqString sub = this.SubString(starpos, this.GetLength() - starpos); if (sub.GetLength() < s.GetLength()) { MessageBox.Show("找不到需要的字符串!"); return -1; } int i, j, v; i = 0; j = 0; while (i < sub.GetLength() && j < s.GetLength()) { if (sub.data[i] == s.data[j]) { i++; j++; } else { i = i - j + 1; j = 0; } } if (j == s.GetLength()) v = i - s.GetLength() + starpos; else v = -1; return v; }
添加回答
举报
0/150
提交
取消