当我在此在线编译器上运行它时,它可以工作 https://www.onlinegdb.com/online_c++_compiler
尽管当我在Windows visual studio上运行它时,它在第13行给了我一个错误
#include <iostream>
#include <string>
using namespace std;
int isUnique(string testing) {
int y = 0;
int z = 1;
int x = testing.capacity() - 1;
while (y < x) {
while (z < x) {
if (testing.at(y) == testing.at(z)) {
std::cout << "The string does not have all unique characters";
exit(1);
}
z++;
}
y++;
z = y + 1;
}
std::cout << "The string has all unique characters";
std::cout << x;
return 0;
}
int main()
{
string x;
getline(cin, x);
isUnique(x);
std::cout << "Hello World";
return 0;
}