SHARE
TWEET

Untitled

a guest Nov 9th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* The main program */
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8.     int delkaSlova;
  9.     char sifra[10];
  10.     char vzoroveSlovo[10];
  11.  
  12.     char posunuteZnaky[10];
  13.  
  14.     int pocetZnakuSifra;
  15.     int pocetZnakuVzor;
  16.  
  17.     // Scanner
  18.     scanf("%d", &delkaSlova);
  19.  
  20.     for(int i = 0; i < delkaSlova; i++){
  21.         scanf("%c", &sifra[i]);
  22.         if(sifra[i] != 0){
  23.             pocetZnakuSifra++;
  24.         }
  25.     }
  26.     printf("\n");
  27.     for(int i = 0; i < delkaSlova; i++){
  28.         scanf("%c", &vzoroveSlovo[i]);
  29.         if(vzoroveSlovo[i] != 0){
  30.             pocetZnakuVzor++;
  31.         }
  32.     }
  33.  
  34.     // Error check
  35.     if(delkaSlova == 0){
  36.         fprintf(stderr, "Error: Chybny vstup!");
  37.         return 100;
  38.     } else if(delkaSlova != pocetZnakuSifra || delkaSlova != pocetZnakuVzor){
  39.         fprintf(stderr, "Error: Chybna delka vstupu!");
  40.         return 101;
  41.     }
  42.  
  43.     void shift(const char *src, char *dst, int offset) {
  44.         for (int i = 0; i < delkaSlova; i++){
  45.             offset = -3;
  46.             if(src[i] < 67 || (src[i] > 96 && src[i] < 99)){
  47.                 offset += 25;
  48.             }
  49.             dst[i] = src[i] + offset;
  50.         }
  51.     }
  52.  
  53.     shift(sifra, posunuteZnaky, -3);
  54.     return 0;
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top