自分のブログ名

物理の空き地 by M.E_K

日々の学び、感じたことを書いております。ブログ移行中->https://physics-mek.com

移転しました。

リダイレクトします。

C++ 文字列に含まれる特定の文字列を数える

移転しました。

リダイレクトします。

#include <string>
#include <sstream>

using namespace std;

int main ()
{
   string str = "*****||||||||||||";
   int count = 0 ;
   for (int i = 0;i < str.size();i++)
   {
       if (str[i] == '*'){count++:}
   }
   cout << count << endl;
}