Дан массив из строчных латинских букв. Вывести на экран в алфавитном порядке все буквы, которые входят в этот текст по одному разу — C++(Си)

#include <stdio.h>
 
const int alph_length = 26;
 
 
int main() {
    int i;
    char text[81];
    char *p;
 
    int letters_encountered[alph_length];
 
    for(i = 0;i< alph_length ; i++ ) 
         letters_encountered[i]=0;
 
    fgets(text,80,stdin);
 
    p = text;
 
    while(*p!=0) {
        if(*p< 'a' || *p > 'z') {
 
            p++;
            continue;
        };
 
        letters_encountered[*(p++) -'a']++;
    };
 
    for(i=0;i<alph_length;i++) { 
        if(letters_encountered[i]==1)
            printf("%c",'a'+(char)i);
 
    };
    return 0;
 
};

Следующий вариант

#include<stdio.h>
 
int Comp(const void* a, const void* b){
    return *(char*)a-*(char*)b;
}
 
int main(){
    char text[]="fghbnggnawqxw", *p=text;
    qsort(text, sizeof(text)-1, sizeof(*text), Comp);
    for(; *p; ++p){
        if(*p==*(p+1)){
            while(*p==*(p+1))++p;
        }
        else{
            printf("%c", *p);
        }
    }
    return 0;
}

Следующий вариант

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
 
int Compare(const void* a, const void* b){
    return *(char*)a-*(char*)b;
}
 
int main(){
    char *matr[]={{"abcemn"},
                   {"fedkpo"},
                   {"ghijqr"},
                   {"xwvuts"},
                   {"yzaala"}}, res[100]={'\0'}, i, *a=res, *b=res;
    for(i=0; i<sizeof(matr)/sizeof(*matr); i++){
        strcat(res, matr[i]);
    }
    qsort(res, strlen(res), sizeof(*res), Compare);
    for(; *b=*a; ++a){
        if(*a!=*(a+1))++b;
    }
    puts(res);
    return 0;
}

7 Thoughts to “Дан массив из строчных латинских букв. Вывести на экран в алфавитном порядке все буквы, которые входят в этот текст по одному разу — C++(Си)”

  1. Wow, incredible blog format! How lengthy have you been running a blog for?
    you made blogging look easy. The whole look of your website is excellent, let alone the content!
    You can see similar here najlepszy sklep

  2. You can definitely see your skills in the work
    you write. The arena hopes for more passionate writers such as you who aren’t afraid to say how they believe.
    All the time go after your heart. I saw similar here: Dobry sklep

  3. Somebody essentially lend a hand to make severely posts I’d state. That is the very first time I frequented your website page and so far? I surprised with the research you made to make this actual put up extraordinary. Wonderful process!

  4. I love reading an article that can make men and women think.
    Also, thank you for permitting me to comment!
    I saw similar here: Sklep online

  5. It’s very interesting! If you need help, look here: ARA Agency

  6. Hey there! Do you know if they make any plugins to assist with SEO?
    I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good gains.
    If you know of any please share. Thanks! You can read
    similar text here: Sklep online

  7. Hello! Do you know if they make any plugins to help with SEO?

    I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good
    gains. If you know of any please share. Kudos! You can read
    similar blog here: E-commerce

Leave a Comment