80分求助

B2110 找第一个只出现一次的字符

__builtin_orz @ 2023-09-17 12:52:45

import Data.List(find)
main::IO()
main=getLine>>=(\s->putStrLn$maybe"no"(:[])$find(\x->(==1)$length$filter(==x)s)s)

by gitmeetcat @ 2023-09-19 22:04:31

c语言

#include <stdio.h>
#include <string.h>
char a[1020];
int main()
{
    scanf("%s", a);
    int len=strlen(a);
    for (int i = 0; i < len; ++i) {
        int num=0;
        for (int j = 0; j < len; ++j)
        {
            if(a[j]==a[i])
            {
                num++;
                if(num>=2)
                    break;
            }
        }
        if(num==1)
        {
            printf("%c",a[i]);
            return 0;
        }
    }
    printf("no");
    return 0;
}

|