pangxia75 发表于 2017-7-10 17:47:11

[华为]字符集合

时间限制:1秒 空间限制:32768K 热度指数:26448

本题知识点: 字符串
题目描述


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



输入描述:

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




输出描述:

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


输入例子:

abcqweracb


输出例子:

abcqwer


#include <string>
#include <iostream>
using namespace::std ;

int main()
   {
      string input;
      
      while(cin>>input)
      {
            string res;   
            if ( input.empty() == true )
                  break ;
                for ( int i = 0; i < input.size(); ++ i )
                {
                  if ( res.find(input)!= string::npos) //查找字符串a是否包含子串b,不是用strA.find(strB) > 0而是strA.find(strB) != string:npos
                        continue ;
                else
                {
                     res.push_back( input );
            }
         }
         
         cout << res << endl ;
      }
}
页: [1]
查看完整版本: [华为]字符集合