#include <stdio.h>
#include <string.h>
#include <stdbool.h>
bool isUnique(char* astr) {
int len;
unsigned char bits[128]={0};
int i;
int index;
if (!astr){
return false;
}
len = strlen(astr);
for (i = 0; i < len; i++) {
index = astr[i];
if (bits[index] == 1) {
return false;
}
bits[index] = 1;
}
return true;
}
int main(){
char str[128]={0};
while(1){
memset(str,0,sizeof(str));
fgets(str,sizeof(str),stdin);
printf("result:%d\r\n",isUnique(str));
}
return 0;
}
package main
import "fmt"
func isUnique(astr string) bool {
bits := make([]byte,128)
for _, v := range astr{
if bits[v] == 1{
return false
}
bits[v] = 1
}
return true
}
func main(){
var str string
for{
_,err := fmt.Scanln(&str)
if err != nil{
fmt.Println("input error :", err)
return
}
fmt.Println("result:",isUnique(str))
}
}