11712

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
1.8 kB
1
Indexable
Never
#include <stdio.h>
#include <string.h>

char str[1000], str2[1000], str3[1000][100];
int main(){
    int n,j,len2;
    char alphe[27][5] = {"*-","-***","-*-*","-**","*","**-*","--*","****",
                        "**","*---","-*-","*-**","--","-*","---","*--*",
                        "--*-","*-*","***","-","**-","***-","*--","-**-",
                        "-*--","--**"};

    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%c", &str[i]);
    }

    j = 0;
    for(int i=0; i<n; i++){
        if(i == n-1){
            str2[j] = '*';
            j++;
        }
        else if(str[i] == '=' && str[i+1] == '=' && str[i+2] == '='){
            str2[j] = '-';
            j++;
            i = i+2;
        }
        else if(str[i] == '=' && str[i+1] == '.'){
            str2[j] = '*';
            j++;
        }
        else if(str[i] == '.' && str[i+1] == '.' && str[i+2] == '.' && str[i+3] == '.' && str[i+4] == '.'){
            str2[j] = '/';
            j++;
            i = i+4;
        }
        else if(str[i] == '.' && str[i+1] == '.' &&str[i+2] == '.'){
            str2[j] = '_';
            j++;
            i = i+2;
        }
        
    }

    int m3 = 0, n3 = 0;
    for(int i=0;i<j;i++){
        if(str2[i] != '_' && str2[i] != '/') {
            str3[m3][n3] = str2[i];
            n3++;
        }
        else if(str2[i] == '/'){
            m3++; n3 = 0;
            str3[m3][n3] = str2[i];
            m3++; n3 = 0;
        }
        else {m3++; n3 = 0;}
    }
 
    for(int i=0; i<=m3; i++){
        if(str3[i][0] == '/'){
            printf(" ");
            continue;
        }
        for(int k=0; k<26; k++){
            if(strcmp(str3[i],alphe[k]) == 0) printf("%c", k+'A');
        }
    }
    printf("\n");

}