字符串过滤后排序

来源:互联网 发布:mac上可以玩的单机 编辑:程序博客网 时间:2024/06/06 01:42
<span style="font-size:18px;">/********************************************************************created:2014/11/28   16:20:00filename: E:\VC\Projects\HDU_0002\HDU_0002\string_sequence.cppfile path:E:\VC\Projects\HDU_0002\HDU_0002file base:HDU_0002file ext:cppauthor:angiaoke*********************************************************************/#include<iostream>#include<string>using namespace std;void string_filter(string s)  {  cout << "please enter a string:";  cin >> s;  int k = s.size();  int i, j;  char out[256];  int b[26] = {0};  for(i = 0; i < k; i++)  {  b[s[i]-'a']++;  }  i = 0;  j = 0;  while(i < 26)  {  if(b[i] > 0)  {  out[j++] = char(i) + 'a';  }  i++;      }  out[j] = '\0';  for(i = 0; i <= j; i++)  {  cout << out[i];  }  }  int main()  {  string s;  string_filter(s);  system("pause");return 0;  }  </span>

0 0
原创粉丝点击