.net如何输出以下内容

来源:百度知道 编辑:UC知道 时间:2024/06/01 04:25:10
以下是规则:
单词 对应值
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次。每五个显示一行.
A~Z只是一种简写,并不是字母.
这个内容是一组字符串,他们之间用空格或逗号隔开.

不知道你的内容是个什么东东 是字符串吗??
如果是字符串你还要考虑空格干什么呀
试试给你弄一下不知道是不是这个意思
function string PrintMethod(string input){
string output = "";
int rowIndex = 1;
for(int i = 1; i<=32; i++){
char c = new AscIIEncoding().GetChar(new byte[]{(byte)(i + 100)});
int count = 0;
foreach(char cc in input.ToCharArray()){
if(cc == c){
count++;
}
}
if(count == 1){
output += "(" + i + ",-)";
}else if(count > 1){
output += "(" + i + "," + count + ")";
}
if(rowIndex%5==0){
output += "\r\n";
}
rowIndex++;
}
reutrn output;
}