here is only basic implementation of problems for beginners. If you have any problem with any solution or any basic concept of programming or you want more efficient solution you can mail me.
my suggestion is not to copy and paste codes from here try to understand the logic and think why you were not able to solve it.

Saturday, 13 September 2014

Spoj encode message

#include<stdio.h>
#include<string.h>
int main(){
int i,j,t,u,p,m,a,b,c;
char ar[10],br[1000],cr[1000];
scanf("%d",&t);
while(t--){
scanf("%s",ar);
scanf("%s",br);
a=strlen(ar);
c=2*a;
b=strlen(br);
for(i=0;i<b;i++){
p=i%c;
if(p<a){
u=br[i]-(ar[p]-48);
}else{
p=c-1-p;
u=br[i]-(ar[p]-48);
}
if(u<97){
u=u+123-97;
}
printf("%c",u);
}
printf("\n");
}
return 0;
}

No comments:

Post a Comment