2015-10-25 30 views

回答

2

找出哪些字母在您的主字符串中可用。然后检查你想要的每封信是否可用。

string S = "RADIOACTIVE"; 
bool avail[26]={false}; 
for(int i=0; i<S.length(); i++) 
    avail[S[i]] = true; 


string s = "REOA"; 
bool All = true; 

for(int i=0; i<s.length(); i++) 
    if(!avail[s[i]]) 
    { 
     All = false; 
     break; 
    } 


if(All) 
    cout << "All letters found" << endl; 
else 
    cout << "All letters not found" << endl; 
相关问题