uva 10815 - Andy's First Dictionary

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1756

好简单的一道题,居然一直runtime erro,么办法咯

 1 #include<iostream>
 2 #include<string>
 3 #include<vector>
 4 #include<algorithm>
 5 #include<sstream>
 6 using namespace std;
 7 vector<string> words;
 8 int main(){
 9     string l;
10     vector<string>::iterator it;
11     while(getline(cin,l)){
12         for(int i=0;i<l.size();i++){
13             if(isupper(l[i]))
14                 l[i]+=32;
15         }
16         istringstream iss(l);        
17         for(string temp;iss>>temp;){
18             int len=0;
19             while(len<temp.size()){
20                 if(isalpha(temp[len])){
21                     len++;
22                     continue;
23                 }
24                 temp.erase(len);
25             }
26             if(temp.empty())
27                 continue;
28             it=find(words.begin(),words.end(),temp);
29             if(it==words.end())
30                 words.push_back(temp);
31         }
32         //iss.clear();
33     }
34     sort(words.begin(),words.end());    
35     for(int i=0;i<words.size();i++)
36         cout<<words[i]<<endl;
37     //system("pause");
38 }

 

posted on 2013-12-10 21:21  云在心  阅读(141)  评论(0)    收藏  举报

导航