using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class caclass
{
public static void ca(string s, out int a, out int b, out int c, out int d)
{
char[] nu = s.ToCharArray();
int x = 0, y = 0, z = 0, m = 0;
for (int i = 0; i < s.Length; i++)
{
if (nu[i] >= 'a' && nu[i] <= 'z')
{ x++; }
else if (nu[i] >= 'A' && nu[i] <= 'Z')
{ y++; }
else if (nu[i] >= '0' && nu[i] <= '9')
{ z++; }
else
{ m++; }
}
a = x;
b = y;
c = z;
d = m;
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入一串字符:");
string s;
s = Console.ReadLine();
int zm, ZM, sz, qt;
caclass.ca(s, out zm, out ZM, out sz, out qt);
Console.WriteLine("您输入的字符串中大写字母的个数为:{0}", ZM);
Console.WriteLine("您输入的字符串中小写字母的个数为:{0}", zm);
Console.WriteLine("您输入的字符串中数字的个数为:{0}", sz);
Console.WriteLine("您输入的字符串中其他字符的个数为:{0}", qt);
Console.ReadKey();
}
}
}
输入一串字符串,运用输出方法计算其中大写 小写 数字 和其他字符的个数
最新推荐文章于 2022-09-28 13:39:24 发布