AlenAntonelli

Gaston, voy a romper todo

Jun 16th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #define n s.size()
  4. using namespace std;
  5.  
  6. string traducir (string s)
  7. {
  8.     string traducida;
  9.  
  10.     for(int i=0; i<n; i++)
  11.     {
  12.         char let = toupper( s[i] );
  13.         if ( 65<=let && let<=90 )
  14.             traducida+=let;
  15.     }
  16.  
  17.     return traducida;
  18. }
  19.  
  20. bool palin (string s)
  21. {
  22.     bool es_pali = true;
  23.     bool no_es_pali = false;
  24.  
  25.     if (!n)
  26.         return no_es_pali;
  27.  
  28.     for(int i=0; i<n/2; i++)
  29.         if ( s[i] != s[n-i-1])
  30.             return no_es_pali;
  31.  
  32.     return es_pali;
  33. }
  34.  
  35. int main()
  36. {
  37.     string s;
  38.     getline(cin,s);
  39.  
  40.     int primer = true;
  41.  
  42.     ofstream out("salida.out");
  43.  
  44.     while (s!="DONE")
  45.     {
  46.         if (!primer)
  47.             cout<<endl;
  48.         primer = false;
  49.  
  50.         s = traducir(s);
  51.  
  52.         if ( palin(s) )
  53.             cout<<"You won’t be eaten!";
  54.         else cout<<"Uh oh..";
  55.  
  56.         getline(cin,s);
  57.     }
  58.  
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment