XAplus!
讨论群:51090447
删吧删吧,把我的号给删了!
现在做出来了,但是不知道这么做好否!!没有用ASCII码
using System;
namespace StringTest
{
class Str
{
static void Main(string[] args)
{
Console.WriteLine("请输入一个字符串,用来统计其中的字符!!\n");
string input=Console.ReadLine();
int countletter=0,countnumber=0,countouther=0;
foreach(char cha in input)
{
if(char.IsLetter(cha))
countletter++;
if(char.IsDigit(cha))
countnumber++;
if(char.IsPunctuation(cha))
countouther++;
}
char [] letter = new char[countletter];
char [] number = new char[countnumber];
char [] outher = new char[countouther];
foreach(char str in input)
{
if(char.IsLetter(str))
letter[--countletter]=str;
if(char.IsDigit(str))
number[--countnumber]=str;
if(char.IsPunctuation(str))
outher[--countouther]=str;
}
Console.WriteLine("\n");
Console.Write("您输入的字母倒序为:");
Console.WriteLine(letter);
Console.Write("您输入的数字倒序为:");
Console.WriteLine(number);
Console.Write("您输入的字符倒序为:");
Console.WriteLine(outher);
}
}
}