[华为]字符集合

时间限制:1秒 空间限制:32768K 热度指数:26448
本题知识点: 字符串

题目描述

输入一个字符串,求出该字符串包含的字符集合

输入描述:
每组数据输入一个字符串,字符串最大长度为100,且只包含字母,不可能为空串,区分大小写。


输出描述:
每组数据一行,按字符串原有的字符顺序,输出字符集合,即重复出现并靠后的字母不输出。

输入例子:
abcqweracb

输出例子:
abcqwer
 1 #include <string>  
 2 #include <iostream>  
 3   
 4 using namespace::std ;
 5 
 6 int main()
 7     {
 8        string input;
 9        
10        
11        while(cin>>input)
12        {
13            string res;    
14            if ( input.empty() == true ) 
15                    break ; 
16                for ( int i = 0; i < input.size(); ++ i ) 
17                {  
18                    if ( res.find(input[i])!= string::npos) //查找字符串a是否包含子串b,不是用strA.find(strB) > 0而是strA.find(strB) != string:npos
19                        continue ;  
20                else 
21                {  
22                     res.push_back( input[i] );  
23              }  
24         }  
25           
26         cout << res << endl ;  
27        }
28 }

 

posted @ 2017-06-01 19:08  懒小小喵  阅读(270)  评论(0编辑  收藏  举报