You are viewing a single comment's thread. Return to all comments →
int main() { int n,i,k; char a[101]; scanf("%d %s %d",&n,a,&k); k%=26; for(i=0;i='a'){ if(a[i]+k>'z') a[i]-=26; a[i]+=k; } else if(a[i]<='Z'&&a[i]>='A'){ a[i]+=k; if(a[i]>'Z') a[i]-=26; } } printf("%s",a); return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Caesar Cipher: Encryption
You are viewing a single comment's thread. Return to all comments →
include
include
include
include
int main() { int n,i,k; char a[101]; scanf("%d %s %d",&n,a,&k); k%=26; for(i=0;i='a'){ if(a[i]+k>'z') a[i]-=26; a[i]+=k; } else if(a[i]<='Z'&&a[i]>='A'){ a[i]+=k; if(a[i]>'Z') a[i]-=26; } } printf("%s",a);
return 0; }