rqnoj 212 提示问题

rqnoj 212 提示问题
细心再细心!宁愿代码长一点,不能在不该出错的地方出错!
以下是我的代码:
#include < iostream >
#include
< string >
using   namespace  std;
bool  yuanyin( char  ch)
{
    
const   string  r( " AEIOUaeiou " );
    
for ( long  i = 0 ;i < 10 ;i ++ )
        
if (ch == r[i])
            
return   true ;
    
return   false ;
}
int  main()
{
    
string  s,one,two,three;
    
long  len,num,n;
    
bool  found;
    
    getline(cin,s);
    
//   Input
    
    one.clear();
    two.clear();
    three.clear();
    
//   Clear
    
    len
= s.length();
    num
= 0 ;
    
for ( long  i = 0 ;i < len;i ++ )
        
if ((s[i] >= ' A ' && s[i] <= ' Z ' ) || (s[i] >= ' a ' && s[i] <= ' z ' ))
        {
            one
+= ' . ' ;
            num
++ ;
        }
        
else  one += s[i];
    
if (num % 3 == 0 || num % 3 == 1 )
        n
= num / 3 ;
    
else  n = num / 3 + 1 ;
    
//   First line
    
    two
= one;
    
for ( long  i = 0 ,j = 0 ;i < len && j < n;i ++ )
        
if ((s[i] >= ' A ' && s[i] <= ' Z ' ) || (s[i] >= ' a ' && s[i] <= ' z ' ))
        {
            two[i]
= s[i];
            j
++ ;
        }
    
//   Second line
    
    three
= two;
    found
= false ;
    
for ( long  i = 0 ,j = 0 ;i < len;i ++ )
    {
        
if ((s[i] >= ' A ' && s[i] <= ' Z ' ) || (s[i] >= ' a ' && s[i] <= ' z ' ))
            j
++ ;
        
if (j == n) i ++ ;
        
if (j >= n && yuanyin(s[i]))
        {
            three[i]
= s[i];
            found
= true ;
        }
    }
    
if ( ! found)
    {
        
if ( 2 * num % 3 == 0 || 2 * num % 3 == 1 )
            n
= 2 * num / 3 ;
        
else  n = 2 * num / 3 + 1 ;
        
for ( long  i = 0 ,j = 0 ;i < len && j < n;i ++ )
            
if ((s[i] >= ' A ' && s[i] <= ' Z ' ) || (s[i] >= ' a ' && s[i] <= ' z ' ))
            {
                three[i]
= s[i];
                j
++ ;
            }
    }
    
//   Third line
    
    cout
<< one << endl << two << endl << three << endl;
return   0 ;
}

你可能感兴趣的:(rqnoj 212 提示问题)