#include #include using namespace std; int broj_podstr(const string& str) { int broj_jedinica = 0; for (auto c : str) { if (c == '1') { broj_jedinica++; } } return broj_jedinica * (broj_jedinica - 1) / 2; } int main(void) { string str = "0110101"; cout << broj_podstr(str) << endl; return 0; }