Code:
#include<stdio.h>
#include<string.h>
int main()
{
char p[50]={0},key[50]={0};
int x=0;
char c[50]={0};
int i,l1,l2;
scanf("%s",p);
scanf("%s",key);
l1=strlen(p);
l2=strlen(key);
if(l1<=l2)
{
goto END;
}
else if(l1>l2)
{
for(i=l2;i<l1;i++)
{
key[i]=key[x];
x++;
}
//printf("\n%s",key);
goto END;
}
END:
for(i=0;i<l1;i++)
{
p[i]=(int)p[i]-64;
key[i]=(int)key[i]-64;
c[i]=p[i]+key[i];
if(c[i]>26)
c[i]=c[i]-26;
c[i]=c[i]+64;
printf("%c",c[i]);
}
return 0;
}
No comments