Last active
June 28, 2016 09:54
-
-
Save PanJarda/163235584e4e0754995257f956e862cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* zadani bylo neco jako vytvorit funkci ktera bude zamenovat znaky podle posunu o naky misto v abecede | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct { | |
char znak; | |
char sifra; | |
} zamena; | |
zamena *vytvor_klic(int posun) { | |
zamena *klic = (zamena *)malloc(26 * sizeof(zamena)); | |
for (int i=0; i<26; i++) { | |
klic[i].znak = i + 'A'; | |
klic[i].sifra = (klic[i].znak - 'A' + posun) % 26 + 'A'; | |
} | |
return klic; | |
} | |
int main() { | |
zamena *klic = vytvor_klic(3); | |
for (int i=0; i<26; i++) | |
printf("%c->%c, ", klic[i].znak, klic[i].sifra); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment