Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***********************************************/
- /** 20140527 Classwork_0514 Question 3 Answer **/
- /** Maker : Yan **/
- /** E-Mail : [email protected] **/
- /** Date : 2014/05/27 pm.04:20 **/
- /***********************************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void main()
- {
- while(1)
- {
- printf("Please input a string: ");
- char input[20] = {EOF};
- scanf("%s", input);
- if((input[0] == '0') && (input[1] == '\0'))
- {
- printf("See You Next Time! Bye Bye!\n");
- system("pause");
- exit(1);
- }
- else
- {
- char output[20] = {EOF};
- for(int i = 0; i < strlen(input); i++)
- {
- if(((int)input[i] >= 65) && ((int)input[i] <= 90))
- {
- output[i] = (char)((int)input[i] + 32);
- }
- else if(((int)input[i] >= 97) && ((int)input[i] <= 122))
- {
- output[i] = (char)((int)input[i] - 32);
- }
- else
- {
- output[i] = input[i];
- }
- }
- printf("The inverse string is: %s.\n", output);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment