Created
June 15, 2014 21:37
-
-
Save anonymous/efaa69ffe8d5af283ff1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstring> | |
using namespace std; | |
bool Unique(string str) | |
{ | |
bool b[256] = {0}; | |
int len = str.length(); | |
for (int i = 0; i < len; ++i) | |
{ | |
int temp = str[i]; | |
if (b[temp]) return false; | |
b[temp] = true; | |
} | |
return true; | |
} | |
int main() | |
{ | |
string str1 = "hello", str2 = "abcd"; | |
cout <<Unique(str1) << " " << endl; | |
cout <<Unique(str2) << " " << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
你好,能解释一下第七行是怎么实现给bool b数组的全部元素赋值的么?