统~计数据问题
比如输入:AAASSSSffffggg111222
显示:
A 3个
S 4个
f 4个
g 3个
数字1 3个
数字2 3个
怎么实现,谢谢!
~~~~~~~~~~~~~
谢谢楼下的
但是输入 “空格就判断错误 了 怎么解决 谢谢!!!
[ 本帖最后由 xiaxun 于 2010-11-19 21:37 编辑 ]
2010-11-19 10:10

2010-11-19 10:16
程序代码:using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
string s = Console.ReadLine();
ArrayList array = new ArrayList();
foreach (char var in s)
{
int count = 0;
for (int i = 0; i < s.Length; i++)
{
if (var==s[i])
{
count++;
}
}
string message = var + " " + count + "个";
if (array.Count!=0)
{
bool check = false;
for (int j = 0; j < array.Count; j++)
{
if (message == array[j].ToString().Trim())
{
check = true;
}
}
if (!check)
{
array.Add(message);
}
}
else
{
array.Add(message);
}
}
for (int i = 0; i < array.Count; i++)
{
Console.WriteLine(array[i].ToString());
}
}
}
}

2010-11-19 10:44
2010-11-19 10:46
2010-11-19 12:00
2010-11-19 12:51
走哪都能碰到高手······
2010-11-19 16:04
2010-11-19 16:24
) 像这样的帖子 俺照删不误 (只要俺还是版主)......
2010-11-19 18:27
2010-11-20 06:21