SHARE
TWEET

Untitled

a guest Dec 6th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define TAMANHO 35
  6.  
  7. void inverteLetras(char* palavra, char*nova);
  8.  
  9. int main()
  10. {
  11.     char palavra[TAMANHO];
  12.     char nova[TAMANHO];
  13.     int i;
  14.     for(i = 0; i < 100; i++){
  15.         scanf("%s", palavra);
  16.         inverteLetras(palavra, nova);
  17.         printf("%s\n", nova);
  18.     }
  19.     return 0;
  20. }
  21.  
  22. void inverteLetras(char* palavra, char*nova){
  23.     char aux;
  24.     int n = strlen(palavra)-1;
  25.     strcpy(nova, palavra);
  26.     if(palavra[0] != palavra[n]){
  27.         aux = nova[0];
  28.         nova[0] = nova[n];
  29.         nova[n] = aux;
  30.     }
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top