Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
986 B
1
Indexable
Never
#include <iostream>
#include <string>

using namespace std;

int main() {
    string input;
    cout << "Enter a string: ";
    cin>>input;

    bool firstStr = true;

    for (char c : input) {
        if (c != 'a' && c != 'b' && c != 'c') {
            firstStr = false;
            break;
        }
    }
    if (firstStr) {
        cout << "String \"" << input << "\" matches the regular expression a+b+c*" << endl;
    } else {
        cout << "String \"" << input << "\" does not match the regular expression a+b+c*" << endl;
    }
    bool secondStr = true;

    for (char d : input) {
        if (d != 'a' && d != 'b' && d != 'c') {
            secondStr = false;
            break;
        }
    }
    if (secondStr) {
        cout << "String \"" << input << "\" matches the regular expression ab*" << endl;
    } else {
        cout << "String \"" << input << "\" does not match the regular expression ab*" << endl;
    }
    return 0;
}