我想要查找複雜數字中的+
或-
的位置。如何在一個操作中使用string :: find來查找「+」或「 - 」
x + y*i
x - y*i
通常情況下,我會做到這一點:
int found = str.find("+");
if (found != string::npos)
cout << "'+' also found at: " << found << endl;
found = str.find("-");
if (found != string::npos)
cout << "'-' also found at: " << found << endl;
我怎能捨棄find
多種選擇單次運行找?
難道你只是檢查'std :: string'的文檔? –
@KirilKirov:抱歉張貼這篇文章,你會原諒我嗎? – ron