日期:2014-05-20 浏览次数:21097 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace WindowsApplication3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            string str = "52B 53A 54B 52B 53A 54B 52B 54B 52A 52B 53B 54A 45B 46A 54B 52A 56B";
            string[] strArr = str.Split(new char[] { ' ' });
            ArrayList al = new ArrayList();
            for(int i=0;i<strArr.Length;i++)
            {
                al.Add(strArr[i]);
            }
            ArrayList alResult =  new ArrayList();
            for (int i = al.Count-1; i > -1; i--)
            {
                string strTmp = al[i].ToString();
                al.RemoveAt(i);
                int iCount = 1;
                for(int j=0;j<al.Count;j++)
                {
                    int index = al.IndexOf(strTmp);
                    if(index<0)
                    {
                        break;
                    }
                    iCount++;
                    al.RemoveAt(index);
                    i--;
                }
                alResult.Add(strTmp+"("+iCount.ToString()+")");
            }
            string strt = string.Empty;
            for(int i=0;i<alResult.Count;i++)
            {
                strt+="\n\r"+alResult[i].ToString();
            }
            MessageBox.Show(strt);
        }
    }
}