Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int
- main ()
- {
- printf ("Please enter letters:\n");
- char ch;
- char closertoz;
- scanf (" %c", &ch);
- if (ch == '#')
- return 0;
- int disfromz = 0;
- if (ch >= 'A' && ch <= 'Z')
- {
- disfromz = (int) ('Z' - ch);
- ch += ('a' - 'A');
- }
- else
- disfromz = (int) ('z' - ch);
- closertoz = ch;
- int maximumfromz = disfromz;
- while (2 > 0)
- {
- scanf (" %c", &ch);
- if (ch == '#')
- {
- printf ("%c", closertoz);
- return 0;
- }
- if (ch >= 'A' && ch <= 'Z')
- {
- disfromz = (int) ('Z' - ch);
- ch = (char) ((int) ch + ((int) ('a' - 'A')));
- }
- else
- disfromz = (int) ('z' - ch);
- if (disfromz < maximumfromz)
- {
- closertoz = ch;
- maximumfromz = disfromz;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement