AlenAntonelli

gaston, voy a romper todo 2

Jun 16th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 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.     ofstream out("salida.out");
  41.  
  42.     while (s!="DONE")
  43.     {
  44.         s = traducir(s);
  45.  
  46.         if ( palin(s) )
  47.             out<<"You won’t be eaten!"<<endl;
  48.         else out<<"Uh oh.."<<endl;
  49.  
  50.         getline(cin,s);
  51.     }
  52.  
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment