rahulb5

Untitled

Apr 18th, 2014
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<cs50.h>
  3. #include<ctype.h>
  4. #include<string.h>
  5.  
  6. int main (int argc , string argv[] )
  7. {
  8. printf("please give me a text : ");
  9. string s = GetString() ;
  10. printf("please enter a key : ");
  11. int k = GetInt() ;
  12. for (int i = 0, n = strlen(s); i < n; i++)
  13. {
  14. int j = s[i] + k ;
  15. if (k >= 26 )
  16. {
  17. k = k % 26 ;
  18. if(isalpha(s[i]))
  19. {
  20. if(isupper(s[i]))
  21. {
  22. if(j>'Z')
  23. {
  24. j = j - 26 ;
  25. printf("%c", j);
  26. }
  27. else
  28. {
  29. printf("%c",j);
  30. }
  31.  
  32. }
  33. if(islower(s[i]))
  34. {
  35. if(j>'z')
  36. {
  37. j = j - 26 ;
  38. printf("%c", j);
  39. }
  40. else
  41. {
  42. printf("%c",j);
  43. }
  44.  
  45. }
  46. }
  47.  
  48. }
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment