Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<cs50.h>
- #include<ctype.h>
- #include<string.h>
- int main (int argc , string argv[] )
- {
- printf("please give me a text : ");
- string s = GetString() ;
- printf("please enter a key : ");
- int k = GetInt() ;
- for (int i = 0, n = strlen(s); i < n; i++)
- {
- int j = s[i] + k ;
- if (k >= 26 )
- {
- k = k % 26 ;
- if(isalpha(s[i]))
- {
- if(isupper(s[i]))
- {
- if(j>'Z')
- {
- j = j - 26 ;
- printf("%c", j);
- }
- else
- {
- printf("%c",j);
- }
- }
- if(islower(s[i]))
- {
- if(j>'z')
- {
- j = j - 26 ;
- printf("%c", j);
- }
- else
- {
- printf("%c",j);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment