谁能告诉我如何执行一个程序来检查字符串中包含的所有独特的字符?
Can anybody tell me how to implement a program to check a string contains all unique chars ?
如果你正在谈论的ASCII字符串:
If you are talking about an ASCII string:
创建一个int数组[0-255]一 为每个字符索引, 初始化为零。
Create an int array [0-255], one for each character index, initialised to zero.
遍历 串中的每个字符和 增加相应阵列位置的字符
Loop through each character in the string and increment the respective array position for that character
如果数组位置已经包含了1,则该字符已经遇到过。结果=>不是唯一的。
If the array position already contains a 1, then that character has already been encountered. Result => Not unique.
如果你到达终点 串没有发生的 (3),结果=>字符串是独一无二的。
If you reach the end of the string with no occurrence of (3), Result => the string is unique.