diff --git a/main.cpp b/main.cpp index 462120d..c37a48b 100644 --- a/main.cpp +++ b/main.cpp @@ -22,10 +22,10 @@ void printlm(T m){ int prompti(string,bool*); int prompti(string,bool*); string prompts(string,bool*); -bool isneg(int); +bool num0b1(int); int main() { - printlm("Get the number of negatives from::"); + printlm("Get the number of 0s before 1 from:"); bool s {}; ilist lst {}; do { @@ -34,10 +34,8 @@ int main() { lst.push_back(v); } } while (s); - printm("Number of negatives (Defined): "); - printlm(count_if(lst.cbegin(), lst.cend(), isneg)); - printm("Number of negatives (Lambda): "); - printlm(count_if(lst.cbegin(), lst.cend(), [] (int x) { return x < 0;})); + printm("Number of 0s before 1: "); + printlm(count_if(lst.cbegin(),lst.cend(), num0b1)); return 0; } @@ -80,6 +78,12 @@ string prompts(string message, bool *status) { return tr; } -bool isneg(int x) { - return x < 0; +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 291a8f3..8da6d3f 100644 Binary files a/main.o and b/main.o differ diff --git a/t b/t index af1fc8c..a7d0c55 100755 Binary files a/t and b/t differ