有关于C++算法

[复制链接]
查看11 | 回复4 | 2008-9-17 17:47:58 | 显示全部楼层 |阅读模式
问题:把"*#####****???$$"字符串 转化成"*1#5*4?3$2"字符串,1、5等这些数字表示前面字符出现的次数。给出算法代码。

回复

使用道具 举报

千问 | 2008-9-17 17:47:58 | 显示全部楼层
请直接拷贝,编译,运行#include #include void convert(const char* src, char* dest, int destSize){
int srcLen = strlen(src);
if (destSize <= 2 * srcLen)
{
printf("size of dest string may not sufficent!\n");
return;
}
char tempDest[100] = {0};
char oldChar = src[...
回复

使用道具 举报

千问 | 2008-9-17 17:47:58 | 显示全部楼层
只给出主要函数的代码。void func(string s){char nowChar=s.substr(0,1);intindex=1;intmaxIndex=s.size();for (int i = 1;i < maxIndex;i++){
char tmp = s.substr(i,1...
回复

使用道具 举报

千问 | 2008-9-17 17:47:58 | 显示全部楼层
与ASCII码一个一个比较就可以了...
回复

使用道具 举报

千问 | 2008-9-17 17:47:58 | 显示全部楼层
个...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行