josiftepe

Untitled

Jan 23rd, 2021
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <ctype.h>
  5. #define MAX 101
  6. int rek(char *niza, int x){
  7.  
  8.     if (*niza != '\0'){
  9.  
  10.  
  11.     if (isalpha(*niza)){
  12.         if (isupper(*niza)){
  13.             if (*niza + x > 'Z'){
  14.                 *niza = 'A' + (*niza + x - 'Z' -1);
  15.             }
  16.             else{
  17.                 *niza+=x;
  18.             }
  19.  
  20.         }
  21.  
  22.         if (islower(*niza)){
  23.             if (*niza + x > 'z'){
  24.                 *niza = 'a' + (*niza + x - 'z'-1);
  25.             }
  26.             else{
  27.                 *niza+=x;
  28.             }
  29.  
  30.         }
  31.  
  32.     }
  33.  
  34.  
  35.     return rek(niza+1,x);
  36.  
  37.     }
  38.    
  39. }
  40.  
  41.  
  42.  
  43. int main(){
  44.  
  45.     int x,n;
  46.     int i;
  47.     scanf("%d %d",&n,&x);
  48.     getchar();
  49.     char niza[MAX];
  50.     for (i=0;i<n;i++){
  51.         scanf("%[^\n]s",&niza[0]);
  52.         getchar();
  53.         rek(niza,x);
  54.         printf("%s\n",niza);
  55.     }
  56.  
  57.  
  58.  
  59.     return 0;
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment