Holey_yan

20140527_KUAS_VisualC++_Classwork_0514_Question_3_Answer

May 27th, 2014
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. /***********************************************/
  2. /** 20140527 Classwork_0514 Question 3 Answer **/
  3. /** Maker  : Yan                              **/
  4. /** E-Mail : [email protected]            **/
  5. /** Date   : 2014/05/27 pm.04:20              **/
  6. /***********************************************/
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11.  
  12. void main()
  13. {
  14.     while(1)
  15.     {
  16.         printf("Please input a string: ");
  17.         char input[20] = {EOF};
  18.         scanf("%s", input);
  19.         if((input[0] == '0') && (input[1] == '\0'))
  20.         {
  21.             printf("See You Next Time! Bye Bye!\n");
  22.             system("pause");
  23.             exit(1);
  24.         }
  25.         else
  26.         {
  27.             char output[20] = {EOF};
  28.             for(int i = 0; i < strlen(input); i++)
  29.             {
  30.                 if(((int)input[i] >= 65) && ((int)input[i] <= 90))
  31.                 {
  32.                     output[i] = (char)((int)input[i] + 32);
  33.                 }
  34.                 else if(((int)input[i] >= 97) && ((int)input[i] <= 122))
  35.                 {
  36.                     output[i] = (char)((int)input[i] - 32);
  37.                 }
  38.                 else
  39.                 {
  40.                     output[i] = input[i];
  41.                 }
  42.             }
  43.             printf("The inverse string is: %s.\n", output);
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment