EQSTR - Biến đổi chuỗi

Tác giả: hieult

Ngôn ngữ: C++

#include <stdio.h>
//#include <conio.h>
#include <string.h>
int main()
{
   // freopen("SNSEQ.inp","r",stdin);
    char s[100],t[100],x[100];
    while(gets(x)>0 )
    {
        if(x[0]!='[')
            continue;
        else if(x[0]=='[' && x[1]=='E')
            break;
        else 
        {
            gets(s);
            gets(t);
            int n = strlen(s);
            for(int i=0;i<n;i++)
            {
                if(s[i]<=t[i] && t[i]-s[i]<13)
                     x[i]=s[i];
                else if(t[i]<s[i] && s[i]-t[i]<13)
                     x[i]=t[i];
                else x[i]='a';
            }
        for(int i=0;i<n;i++)
            printf("%c",x[i]);
        printf("\n");
        }
    }
  //  getch();
}

Download