以下是规则:
单词    对应值
A         1
B         2

Z         26问题一:有以下内容,中间用空格隔开
A  B  C  D  E
F  G  H  I  G请问如何才能得到以下输出结果:
(1,-)  (2,-)  (3,-)  (4,-)  (5,-)
(6,-)  (7,2)  (8,-)  (9,-)说明:字母A对应数字1,依次类推,-表示出现次数,如出现1次就用-表示,如出现2次就用2表示,出现3就用3表示...等等,例如G出现2次。每五个显示一行. 

解决方案 »

  1.   

     string[] s = new string [] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
                string value = "<table><tr><td>单词</td><td>对应值</td></tr>";
                for (int i = 0; i < s.Length; i++)
                {
                   int j=i+1;
                   value += "<tr><td>" + s[i] + "</td><td>" + j + "</td></tr>";
                }
                value += "</table>";
                Response.Write(value);
      

  2.   

    其实第一题还可以这样算。其实char类型也是可以++的
       string value = "<table><tr><td>单词</td><td>对应值</td></tr>";
                char g = 'A';
                for (int i = 1; i < 27; i++)
                {
                    value += "<tr><td>" + g + "</td><td>" + i + "</td></tr>";
                    g++;
                }
                value += "</table>";
                Response.Write(value);
      

  3.   

    如果楼主想知道是怎样转换ascll编码的话 
    可以这样
       string value = "<table><tr><td>单词</td><td>对应值</td></tr>";
                char g = 'A';
                for (int i = 1; i < 27; i++)
                {
                    int asc = Convert.ToInt16(g);
                    value += "<tr><td>" + g + "</td><td>" + i + "&nbsp;他的ascll编码是:"+asc+"</td></tr>";
                    g++;
                    
                }
                value += "</table>";
                Response.Write(value);
      

  4.   

    string s=值;
    string[] count = new string [] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; for (int i=1;i<28;i++){
    if(i%5=0){
    //输出换行符号
    }
    //输出(i,Getcount(count[i]))
    }
    public int Getcount(string letter){
    //根据循环,字符串的截取和查找...来解析s}
      

  5.   

    以下是规则: 
    单词    对应值 
    A        1 
    B        2 
    … 
    Z        26 问题一:有以下内容,中间用空格隔开 
    A  B  C  D  E 
    F  G  H  I  G 请问如何才能得到以下输出结果: 
    (1,-)  (2,-)  (3,-)  (4,-)  (5,-) 
    (6,-)  (7,2)  (8,-)  (9,-) 说明:字母A对应数字1,依次类推,-表示出现次数,如出现1次就用-表示,如出现2次就用2表示,出现3就用3表示...等等,例如G出现2次。每五个显示一行.protected void Page_Load(object sender, EventArgs e)
            {
                //定义可以出现的字符次数
                string[] s = new string [] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
                //设定一共出现多少个
                int totalCount = 20;
                //设定每行显示多少个
                int rowCout = 5;
                //标题
                string title = "";
                //值
                string value = "";
                Random r = new Random((int)DateTime.Now.Ticks);
                for (int i = 0; i < totalCount; i++)
                {
                    //随机取出一个数
                    int currentIndex = (int)(r.Next(0,s.Length));
                    //每输出规定个数就换行
                    if (i%rowCout ==0)
                    {
                        value += "<br>";
                        title += "<br>";
                    }
                    //当前要出现的数字
                    string currentTitle = s[currentIndex];
                    
                    title += currentTitle+"&nbsp";
                    Regex regex = new Regex(currentTitle,RegexOptions.Compiled);
                    MatchCollection matchsAll = regex.Matches(title);
                    //已经出现的次数
                    int currentCount= i+1;
                    string appearCount = matchsAll.Count.ToString();
                    if(appearCount=="1")
                        appearCount ="-";
                    value += "("+currentCount+","+appearCount+")&nbsp";
                }
                string result = title + "<br><br>" + value;
                Response.Write(result);}本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/kimizhou_blog/archive/2009/11/30/4908301.aspx