Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. //Gilbert Zhuo z5311591
  2. //30/3/2020
  3.  
  4. #include <stdio.h>
  5. #include <ctype.h>
  6.  
  7. int main (void) {
  8. char sub[26];
  9. for(int i = 0; i < 26; i++) {
  10. sub[i] = getchar();
  11. }
  12. int ch = getchar();
  13.  
  14. while(ch != EOF) {
  15. //Lower case
  16. if (ch >= 97 && ch <= 122) {
  17. printf("%c",sub[ch-97]);
  18. }
  19. //Upper Case
  20. else if (ch >= 65 && ch <= 90) {
  21. printf("%c",toupper(sub[ch-65]));
  22.  
  23. }
  24. else {
  25. printf("%c", ch);
  26. }
  27.  
  28. ch = getchar();
  29. }
  30.  
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement