课程元素类型 任务
随机产生100个大小写字母,统计其中各元音字母(不分大小写)的个数。
总结:char型不能直接赋值给string型。
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace sj_5_5 { class Program { static void Main(string[] args) { int[] dA; int i,j,n; i = 0; j = 0; n = 0; dA = new int[100]; Random r = new Random(); while (i < 100) { j = r.Next(65, 123); if (j < 91 || j > 96) { dA[i] = j; i++; } } for (i = 0; i < 100; i++) { if (dA[i] == 'A' || dA[i] == 'a' || dA[i] == 'e' || dA[i] == 'E' || dA[i] == 'i' || dA[i] == 'I' || dA[i] == 'o' || dA[i] == 'O' || dA[i] == 'u' || dA[i] == 'U') { n++; } Console.Write(Convert.ToChar(dA[i])); } Console.Write("\n"+n); Console.ReadKey(); } } }