#include #include #include #include #include using namespace std; bool is_unique(const char* p, size_t n) { // ASCII range is 32-126 vector counts(95, false); for (size_t i = 0; i < n; ++i, ++p) { char c = *p; cout << c << endl; if (c < 32) throw exception(); size_t pos = c - 32; if (pos >= 95) throw exception(); if (counts[pos]) return false; counts[pos] = true; } return true; } int main(int argc, char** argv) { if (argc < 2) { cout << "needs at least one argument" << endl; return EXIT_FAILURE; } cout << "input string: " << argv[1] << endl; size_t n = strlen(argv[1]); const char* p = argv[1]; try { cout << "all characters are unique: " << (is_unique(p, n) ? "yes" : "no") << endl; } catch (...) { cout << "failed to parse the string" << endl; } return EXIT_SUCCESS; }