计数排序
来源:互联网 发布:天庭淘宝店txt下载 编辑:程序博客网 时间:2024/05/09 10:15
线性时间时间复杂度, 但需要一定的空间开销,并且要知道大致范围。没有重复的,可以用bitmap表示
char * coutSort(char *pStr)
{assert(pStr!=NULL && *pStr!='\0') ;
int hash[256]={0};
char *p=pStr;
while(*p!='\0')
{
hash[ *p++] ++;
}
p=pStr;
for(int i=0;i<256;++i)
{
if(hash[i]!=0)
{
for(int j=0;j<hash[i];++j)
*p++ = (char)i;
}
}
return pStr;
}
int main()
{
char pStr[]="asdfadf234wdSD23";
coutSort(pStr);
cout<<pStr<<endl;
return 0;
}
- 计数排序
- 计数排序
- 计数排序
- 计数排序
- 计数排序
- 计数排序
- 计数排序
- 计数排序
- 计数排序
- 计数排序
- 计数排序
- 计数排序
- 计数排序
- 计数排序
- 计数排序
- 计数排序
- 计数排序
- 计数排序
- Google 搜索技巧
- oracle表空间转换
- win7+vs2010+opnet教程
- 小羊驼和你一起学习cocos2d-x与lua之一(迭代器pairs 和 ipairs区别)
- linux下的find文件查找命令与grep文件内容查找命令
- 计数排序
- CursorWindow can not be created due to cursor [memory] leak
- Freemarker语法简介
- Struts2获取request
- 每个C程序员应该知道的未定义行为#2/3
- MyBitis(iBitis)系列随笔之一:MyBitis入门实例
- C++ 线程池的封装实现
- iBatis的remapResults属性
- Android 程序退出的办法以及监听并处理用户按下back键的方法