Advertisement
LightProgrammer000

Palíndromo

Nov 28th, 2018
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.88 KB | None | 0 0
  1. /// Bibliotecas
  2. #include <string>
  3. #include <conio.h>
  4. #include <locale.h>
  5. #include <stdlib.h>
  6. #include <iostream>
  7. using namespace std;
  8.  
  9. /// Funções
  10. void Palidromo( string a);
  11.  
  12. /// Programa
  13. int main( int argc, char *argv [] )
  14. {
  15.     // Sistemas
  16.     setlocale(LC_ALL, "");
  17.  
  18.     // Variáveis
  19.     string a;
  20.     int loop = 1;
  21.  
  22.     while(loop == 1)
  23.     {
  24.         // Apresentação
  25.         cout << endl;
  26.         system("cls & color B");
  27.         system(" echo  ==============================");
  28.         system(" echo  - Usuario: %username%");
  29.         system(" echo  - Computador: %computername%");
  30.         system(" echo  - Hota: %time:~0,-3%");
  31.         system(" echo  - Data: %date%");
  32.         system(" echo  ==============================");
  33.         cout << endl;
  34.  
  35.         cout << "\n ========== Programa das Frases ========== " << endl;
  36.  
  37.         // Procedimentos
  38.         cout << "\n - Digite uma Frase : ";
  39.         getline(cin, a);
  40.         Palidromo(a);
  41.  
  42.         cout << "\n ========================================= \n\n" << endl;
  43.         system("pause");
  44.     }
  45.  
  46.     return(0);
  47. }
  48.  
  49. ////////////////////////////// FUNÇÕES //////////////////////////////
  50. void Palidromo( string a )
  51. {
  52.     int i;
  53.     string b = "";
  54.     string c = "";
  55.  
  56.     for ( i = 0; i < a.size(); i++ )
  57.     {
  58.         b += a[i];
  59.     }
  60.  
  61.     for( i = a.size() - 1 ; i >= 0; i-- )
  62.     {
  63.         c += a[i];
  64.     }
  65.  
  66.     if ( b == c )
  67.     {
  68.         system("color A");
  69.         cout << " - Palavra [Sentido Correto]: " << b << endl;
  70.         cout << " - Palavra [Sentido Reverso]: " << c << endl;
  71.         cout << " - Resultado: Palíndromo" << endl;
  72.     }
  73.  
  74.     else
  75.     {
  76.         system("color C");
  77.         cout << " - Palavra [Sentido Correto]: " << b << endl;
  78.         cout << " - Palavra [Sentido Reverso]: " << c << endl;
  79.         cout << " - Resultado: Não é Palíndromo" << endl;
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement