//生成答案
char[] strAnswer = new char[4] { 'A', 'B', 'C', 'D' };
string strScore = string.Empty;
Random r = new Random();
for (int i = 0; i < 3; i++)
{
int index = r.Next(3);
strScore += strAnswer[index];
index = r.Next(1, 10);
strScore += index;
}
Console.WriteLine(strScore);
//切割答案
for (int i = 0; i < strAnswer.Length; i++)
{
strScore=strScore.Replace(strAnswer[i], ',');
}
Console.WriteLine(strScore);
string[] strSum = strScore.Split(',');
//计算总分
int sum = 0;
for (int i = 1; i < strSum.Length; i++)
{
sum += Convert.ToInt32(strSum[i]);
}
Console.WriteLine("总分:" + sum);
Console.Read();