zoukankan      html  css  js  c++  java
  • 去掉字符串中重复的字符

    #include <iostream>

    #include <string>

    using namespace std;

    char *deletechar(char*inputstr,char *outputstr)

    {

           char *deststr=outputstr;

           bool table[26]={false};

           int k=0;

           for (int i=0;i<strlen(inputstr);i++)

           {

                  char c=inputstr[i];

                  if (table[c-'a']==false)

                  {

                         outputstr[k++]=c;

                         table[c-'a']=true;

                  }

           }

           outputstr[k]='';

           return deststr;

    }

    void main()

    {

           char str1[]="aaaabdcadjoiufdjouj";

           char *deststr=new char[strlen(str1)+1];

           memset(deststr,0,strlen(str1)+1);

           cout<<deletechar(str1,deststr);

    }

  • 相关阅读:
    习题解答chapter-01
    Java-chapter-01 菜鸟初见Java
    ijkdemo
    1027
    avformat_seek_file
    pla
    android1010横屏等
    文件浏览对话框
    智能指针处理---bo
    Js为Dom元素绑定事件须知
  • 原文地址:https://www.cnblogs.com/fuyanan/p/3354241.html
Copyright © 2011-2022 走看看