Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
文字列比較関数を使用するのではなく、各文字を反復処理して C++ で等価性をテストすることにより、文字列が別の文字列に存在するかどうかを確認するにはどうすればよいですか?
string one="hello world"; // Search *in* this string string two="wor"; // Search *for* this string
宿題みたい^^
int find(string one, string two){ int a, b; for(int c = 0; c + two.length() < one.length(); c++){ a = 0; b = c; while(a < two.length() && one[b++] == two[a++]); if(a == two.length())return c; } return -1; }