Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5.  
  6. char* inverte_string(char * str){
  7.     char *v;
  8.     int i=0,j,n;
  9.  
  10.     n=strlen(str);
  11.  
  12.     v=(char*)malloc((n+1)*sizeof(char));
  13.     while (str[i] != 0){
  14.         if (str[i]>= 'a' && str[i]<='z'){
  15.             v[i]='z'-str[i]+'a';
  16.         }
  17.         else if(str[i]>='A' && str[i] <= 'Z'){
  18.             v[i]= 'Z'-str[i]+'A';
  19.         }
  20.         i++;
  21.     }
  22.  
  23.    
  24.     v[i]='\0';
  25.  
  26.  
  27.     return v;
  28.  
  29. }
  30.  
  31.  
  32.  
  33. int main(){
  34.  
  35.     char str[]="Aluno";
  36.     char *v;
  37.  
  38.     v=inverte_string(str);
  39.  
  40.     printf("%s\n", v);
  41.  
  42.     return 0;
  43.  
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement