遍历要查找的字符在字符串中出现的次数! C#程序的实例:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
string str = "AUIFUIVBNUEGFJKEI";
int all = 0;//计数器
for (int i = 0; i < str.Length; i++)
{
//每次取出一个字符
char c = str[i];
if (c == 'a' || c == 'A')
{
all++;
}
if (c == 'i' || c == 'I')
{
all++;
}
if (c == 'o' || c == 'O')
{
all++;
}
if (c == 'u' || c == 'U')
{
all++;
}
if (c == 'e' || c == 'E')
{
all++;
}
}
Console.WriteLine("总共有{0}个元音",all);
}
}
}