diff --git a/main.cpp b/main.cpp index c37a48b..0712d0b 100644 --- a/main.cpp +++ b/main.cpp @@ -22,7 +22,6 @@ void printlm(T m){ int prompti(string,bool*); int prompti(string,bool*); string prompts(string,bool*); -bool num0b1(int); int main() { printlm("Get the number of 0s before 1 from:"); @@ -35,7 +34,8 @@ int main() { } } while (s); printm("Number of 0s before 1: "); - printlm(count_if(lst.cbegin(),lst.cend(), num0b1)); + const auto the1 = find(lst.cbegin(),lst.cend(),1); + printlm(count(lst.cbegin(),the1, 0)); return 0; } @@ -77,13 +77,3 @@ string prompts(string message, bool *status) { *status = true; return tr; } - -bool num0b1(int x) { - static bool has1 {}; - if (x == 1) has1 = true; - if (has1 || x != 0) { - return false; - } else { - return true; - } -} diff --git a/main.o b/main.o index 8da6d3f..0bea9f4 100644 Binary files a/main.o and b/main.o differ diff --git a/t b/t index a7d0c55..e78c877 100755 Binary files a/t and b/t differ