//统计重复字符串 如  eeefffkkkhjk 得到如下结果 3e3f3khjk;

 string zipStr = Console.ReadLine();
var charList = zipStr.ToCharArray();
var listArray = new List<char>();
foreach (var item in charList)
{
if (!listArray.Contains(item))
{
listArray.Add(item);
}
}
var dic = new Dictionary<string, string>();
int count = ;
foreach (var item in listArray)
{
foreach (var o in charList)
{
if (item == o)
{
count++;
}
}
dic.Add(item.ToString(),count.ToString());
count = ;
}
string resutl = string.Empty;
foreach (var item in dic)
{
if (Convert.ToInt32(item.Value)<=)
{
resutl += item.Key; }
else
{ resutl += item.Key + item.Value;
}
}
Console.WriteLine(resutl);
Console.Read();

统计重复字符串 如 eeefffkkkhjk 得到如下结果 3e3f3khjk;的更多相关文章

  1. Leetcode 466.统计重复个数

    统计重复个数 定义由 n 个连接的字符串 s 组成字符串 S,即 S = [s,n].例如,["abc", 3]="abcabcabc". 另一方面,如果我们可 ...

  2. Java实现 LeetCode 466 统计重复个数

    466. 统计重复个数 定义由 n 个连接的字符串 s 组成字符串 S,即 S = [s,n].例如,["abc", 3]="abcabcabc". 另一方面, ...

  3. python--基础学习(四)自然字符串、重复字符串、子字符串

    python系列均基于python3.4环境 1.自然字符串和重复字符串 代码示例: str1=r'hello \npython' str2='hello \npython' str3="h ...

  4. Linux 统计某个字符串出现的次数

    要统计一个字符串出现的次数,这里现提供自己常用两种方法: 1. 使用vim统计 用vim打开目标文件,在命令模式下,输入 :%s/objStr//gn 即可 2. 使用grep: grep -o ob ...

  5. sql统计重复数据

    sql代码如下: 统计重复的数据 select MingCheng from tabShouFeiGongShi group by MingCheng having count(MingCheng) ...

  6. asp正则过滤重复字符串的代码

    asp下过滤重复字符串的代码,有时候我们需要过滤一些重复的字符串,下面的代码即可解决这个问题 比如 1223445677777778aabbcccccccccc 经过过滤之后就是12345678abc ...

  7. Java基础知识强化之集合框架笔记27:ArrayList集合练习之去除ArrayList集合中的重复字符串元素

    1. 去除ArrayList集合中的重复字符串元素(字符串内容相同) 分析: (1)创建集合对象 (2)添加多个字符串元素(包含重复的) (3)创建新的集合 (4)遍历旧集合,获取得到每一个元素 (5 ...

  8. Oracle 去掉重复字符串

    create or replace function remove_same_string(oldStr varchar2, sign varchar2) return varchar2 is /** ...

  9. Repeated Substring Pattern --重复字符串

    Given a non-empty string check if it can be constructed by taking a substring of it and appending mu ...

随机推荐

  1. 更改CentOS 6.3 yum源为国内 阿里云源

    将CentOS的 yum源 更换为 阿里云源 1.备份 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.b ...

  2. 查找可用的谷歌IP地址

    在终端下运行命令就可以: nslookup www.google.cn 就可以找到

  3. RxJava 中文文档

    https://mcxiaoke.gitbooks.io/rxdocs/content/Subject.html

  4. Java性能监控工具:VisualVM

    VisualVM是JDK自带的一款全能型性能监控和故障分析工具,包括对CPU使用.JVM堆内存消耗.线程.类加载的实时监控,内存dump文件分析,垃圾回收运行情况的可视化分析等,对故障排查和性能调优很 ...

  5. pidera安装node.js(树莓派)

    1. 下载node.js wget http://nodejs.org/dist/v0.10.5/node-v0.10.5-linux-arm-pi.tar.gz tar -xzvf node-v0. ...

  6. 数学图形(1.39)TN constant curve

    这是个类似巴黎铁塔的曲线. #http://www.mathcurve.com/courbes2d/tn/tn.shtml vertices = t = to (PI*0.999) a = s = s ...

  7. Delphi DBGrid图显用法

    procedure TForm10.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;DataCol: Integer; Column: ...

  8. docker仓库操作

    1.登陆注册 docker login 2.搜索镜像 docker search xxx 3.上传镜像 docker push 镜像名:标签或者镜像ID 4.下载镜像 docker pull 镜像名: ...

  9. java 内存泄漏和内存溢出

    参考:https://blog.csdn.net/eff666/article/details/52784724 1.内存溢出  内存溢出:OOM(OutOfMemoryError)异常,即程序需要内 ...

  10. 介绍Visual Studio的Android模拟器

    介绍Visual Studio的Android模拟器 http://blogs.msdn.com/b/visualstudioalm/archive/2014/11/12/introducing-vi ...