Advertisement
Guest User

j3j3m0nC0D3FiNaL

a guest
Feb 19th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.93 KB | None | 0 0
  1. #include <stdio.h>
  2. #define MAX 18
  3.  
  4.  
  5. int charcount(char aInput[]){//returns the number of characters in the input
  6.    
  7.     int i = 0;
  8.              
  9.     while(i < MAX){
  10.        
  11.         if(aInput[i] == 0)
  12.             return i;  
  13.        
  14.    
  15.       i++;
  16.    
  17.     }
  18. }
  19.  
  20. void j3j3m0n(char aInput[], int nLetter){//this function translates normal words into j3j3m0n w0rDes
  21.    
  22.     int i = 0;
  23.    
  24.     while(i < nLetter){
  25.         {
  26.        
  27.         if (aInput[i] == 'o' || aInput[i] == 'O')//changes 'o' or 'O' to '0'(zero)
  28.             aInput[i] = '0';
  29.    
  30.         if (aInput[i] == 'e' || aInput[i] == 'E')//changes 'e' or 'E' to '3'
  31.             aInput[i] = '3';
  32.    
  33.         }
  34.         i++;
  35.     }
  36.        
  37.     if (aInput[i - 1] == '0'){//if the last character is '0'(zero), adds 'w' and 'z' at the end
  38.         aInput[i] = 'w';
  39.         aInput[i + 1] = 'z';
  40.         nLetter += 2;
  41.     }  
  42.        
  43.     i = nLetter;
  44.     if (aInput[0] == 's'){//if the first and/or letter is 's', replaces 's' with 'e' and 's'
  45.         while (i > 0){
  46.             aInput[i] = aInput[i - 1];
  47.             i++;
  48.         }
  49.         aInput[0] = 'e';
  50.     }  
  51.    
  52.     i = 0;
  53.     while (i < nLetter){//makes the output alternate from lower case to upper case via ASCII, respectively
  54.        
  55.         if((i % 2) == 1 && aInput[i] >= 97 && aInput[i] <= 122)
  56.             aInput[i] -= 32;
  57.            
  58.         else if ((i % 2) == 0 && aInput[i] >= 65 && aInput[i] <= 90)
  59.             aInput[i] += 32;
  60.            
  61.     i++;
  62.     }
  63. }
  64.  
  65.  
  66. int main(){
  67.    
  68.     char aInput[MAX];
  69.     int nLetter;
  70.    
  71.     printf("Enter a word: ");//asks user for input
  72.     scanf("%15s", aInput);
  73.    
  74.     nLetter = charcount(aInput);//counts how many letters are in the word (15 character limit)
  75.    
  76.     j3j3m0n(aInput, nLetter);//calls the function to translate the word to j3j3m0n
  77.    
  78.     printf("j3j3m0n r3sUlT: %s", aInput);//displays j3j3m0n translation
  79.    
  80.     return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement