Advertisement
Infernale

Simple Encryption

Dec 7th, 2018
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(){
  5.     int tc, n;
  6.     char in[1001];
  7.     scanf("%d",&tc);
  8.     for(int i=1;i<=tc;i++){
  9.         scanf("%d",&n);
  10.         getchar();
  11.         scanf("%[^\n]",in);
  12.         for(int j=0;j<strlen(in);j++){
  13.             if(in[j]>64 && in[j]<91){
  14.                 if(in[j]+n>90){
  15.                     in[j]=65+((n-(91-in[j]))%26);
  16.                 }else{
  17.                     in[j]+=n;
  18.                 }
  19.             }
  20.             if(in[j]>96 && in[j]<123){
  21.                 if(in[j]+n>122){
  22.                     in[j]=97+((n-(123-in[j]))%26);
  23.                 }else{
  24.                     in[j]+=n;
  25.                 }  
  26.             }
  27.         }
  28.         printf("Case #%d: ",i);
  29.         for(int j=0;j<strlen(in);j++){
  30.             printf("%c",in[j]);
  31.         }
  32.         printf("\n");
  33.     }
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement