-
Write a function that takes a string and returns the ROT13 version of the string; you may assume that the character set is ascii. What is the meaning of “Cebtenzzvat Cenkvf vf sha!”0
-
Member • Dec 14, 2011
Iterate over each character in the string.
If the character is an alphabet, add or subtract 13 from its ascii value, depending on the alphabet.
If it's a non-alphabet, keep it as it is.Are you sure? This action cannot be undone. -
Member • Dec 14, 2011
And "Cebtenzzvat Cenkvf vf sha" translates to "programming in praxis is fun"
P.S I can't seem to be able to post python code. When I add the code in the reply and try to post, an error message saying "Internal server error" appears.
Without the code, it seems to be ok.Are you sure? This action cannot be undone. -
Member • Dec 14, 2011
The code could be,
#include<stdio.h> #include<string.h> int main() { char s[50],new[50];int len,i,temp; printf("Enter The String To Be Encrypted"); gets(s); len=strlen(s); for(i=0;i<len;i++) { if(s[i]>64&&s[i]<91) { if(s[i]>77) s[i]=s[i]-13 else s[i]=s[i]+13 } else if(s>96&&s<123) { if(s>109) s[i]=s[i]-13 else s[i]=s[i]+13 } } printf("The ROT13 Version Of The String Is\n\n"); printf("%s",s); }
Are you sure? This action cannot be undone. -
Member • Dec 14, 2011
sorry dude.. actually i was unable to post that code.. can't get that "[]" in the code.. datz y i deleted itAre you sure? This action cannot be undone. -
Administrator • Dec 14, 2011
Wrap it in the 'code' tags.Mystique_Mythsorry dude.. actually i was unable to post that code.. can't get that "[]" in the code.. datz y i deleted itAre you sure? This action cannot be undone. -
Member • Dec 14, 2011
Hmm.. I can post C code, but not Python code?? :OAre you sure? This action cannot be undone.