编写代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _1
{
class Program
{
static void Main(string[] args)
{
char c;
int sum = 0;
do
{
c = (char)Console.Read();
if (c >= '0' && c <= '9')
{
int num = c - '0';
sum += num;
}
if(c=='*')
{
sum += 500;
}
}
while (c != '#');
Console.WriteLine("结果为:" + sum);
Console.ReadKey(true);
}
}
}
程序运行结果如下: