输出字符串中只出现一次的字符
2015-10-06 14:37
357 查看
#include#includeusing namespace std;void getonce (char *str){int hash[256] ={0};int k=0;char *order=(char *)malloc(strlen(str)+1);while(*str != '\0'){hash[int(*str)]++;if (hash[int(*str)] == 1)order[k++] = *str;str++;}order[k] = '\0';k=0;while(order[k]!='\0'){if(hash[int(order[k])]
== 1)cout<<order[k]<<endl;k++;}}int main(){ char *s="abdfdfacef";getonce(s);return 0;}
== 1)cout<<order[k]<<endl;k++;}}int main(){ char *s="abdfdfacef";getonce(s);return 0;}
相关文章推荐
- 启动入口Start.java分析
- C++模板
- 并查集
- Debug Assertion Failed! File:cmdtarg.cpp Line:52
- http的报文结构和状态码的含义
- extern用法
- java springmvc 定时器方法执行两次问题
- KMP 求next数组
- 利用jdk的wsimport.exe生成WebServices客户端代码
- http的报文结构和状态码的含义
- VMware虚拟机运行时出错:cannot open the disk xxxxxxxxxxx.vmdk. failed to lock the file
- 大数据机器学习系统研究进展
- android:theme和app:popupTheme的作用,以及在android 3.0以下不起作用问题的解决
- UVA 10256 The Great Divide
- C++中的struct和class的区别
- OFBiz部署与运行
- java进销存总结
- POJ 2752 KMP中next数组的理解
- CentOS中文件夹基本操作命令
- Zend Guard Run-time support missing问题的解决