#include #include using namespace std; bool isValidExponentialNumber(const string& input) { bool hasE = false; bool hasDot = false; bool hasDigit = false; for (char ch : input) { if (ch == 'e' || ch == 'E') { // Check if 'e' occurs more than once or it's the first character if (hasE || !hasDigit) { return false; } hasE = true; hasDot = true; // Disallow dots after 'e' } else if (ch == '.') { // Check if '.' occurs more than once or after 'e' if (hasDot || hasE) { return false; } hasDot = true; } else if (ch == '+' || ch == '-') { // Only allow '+' or '-' right after 'e' if (hasE && input.find(ch, input.find('e')) == string::npos) { return false; } } else if (isdigit(ch)) { hasDigit = true; } else { // Invalid character return false; } } // The input is valid if it contains at least one digit return hasDigit; } int main() { string input; cout << "Enter a potential exponential number: "; cin >> input; if (isValidExponentialNumber(input)) { cout << "Valid exponential number." << endl; } else { cout << "Invalid exponential number." << endl; } return 0; }