zoukankan      html  css  js  c++  java
  • 编程实践55

    课程元素类型 任务

    随机产生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();
            }
        }
    }
  • 相关阅读:
    Python—re模块
    Python—json模块
    Python—sys模块介绍
    Python—os模块介绍
    Python—randonm模块介绍
    Python—time模块介绍
    Python—包介绍
    Python—模块介绍
    Python—装饰器
    jvm、jre、jdk
  • 原文地址:https://www.cnblogs.com/Wzqa/p/2790410.html
Copyright © 2011-2022 走看看