@xAtom
917 / 742 / 60
Регистрация: 09.12.2010
Сообщений: 1,346
|
03.01.2012, 15:47
|
|
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| int long_seq(const CString str, const TCHAR ch) {
int c, tmp = 0;
const int len = str.GetLength();
for(int pos = 0; (pos = str.Find(ch, pos)) != -1; pos += c) {
for(c = pos; str.GetAt(c) == ch && c < len; c++);
c -= pos;
if(c >= tmp)
tmp = c;
}
return tmp;
}
void CMFCDlg::OnButton()
{
CString s = _T("abc , aaa_kaaaaaa...aaaaa");
int cnt = long_seq(s, 'a');
s.Format(_T("%d"), cnt);
MessageBox(s, s, MB_OK | MB_ICONINFORMATION);
} |
|
0
|