Advertisement
sellmmaahh

rot13

Feb 6th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define vel 15
  4.  
  5. void unos(char* string)
  6. {
  7.     int i=0;
  8.     char c;
  9.     do {
  10.         c=getchar();
  11.         string[i]=c;
  12.         i++;
  13.     } while (c!='\n' && i<vel);
  14.     string[i-1]=='\0';
  15. }
  16. void rot13 (char* string)
  17. { while (*string!='\0')
  18. {
  19.     if ((*string>='a' && *string<='m') || (*string>='A' && *string<='M'))
  20.         *string+=13;
  21.     else if ((*string>='n' && *string<='z') || (*string>='N' && *string<='Z'))
  22.         *string-=13;
  23.     string++;
  24. }
  25.  
  26. }
  27. int main ()
  28. {
  29.     char* rijec[vel];
  30.     int i=0;
  31.     printf("Unesite rijec do 15 znakova: ");
  32.     unos(rijec);
  33.     rot13 (rijec);
  34.     printf("%s", rijec);
  35.     return 0;
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement