Esempio n. 1
0
        static void Main(string[] args)
        {
            //1---要求输入整数
            int num = SectionH.ReadInteger();

            //2---打印array
            int[] A = new int[num];
            SectionH.PrintArray(A);

            //3---看s1里有没有s2
            Console.WriteLine("Please give us s1 and s2. We are going to check if s1 includes s2(regardless of capital letters).");
            Console.Write("Please enter s1:");
            string s1 = Console.ReadLine();

            Console.Write("Please enter s2:");
            string s2 = Console.ReadLine();

            SectionH.Instring(s1, s2);

            //4---显示s1中s2的开始位置
            SectionH.FindWord(s1, s2);

            //5---十六进制
            //使用第一题输入的num
            SectionH.hexadecimal(num);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            //1---要求输入整数
            int num = SectionH.ReadInteger();


            //2---打印array
            int[]  A2 = new int[num];
            Random r  = new Random();
            int    j  = 0;

            for (j = 0; j < num; j++)
            {
                A2[j] = r.Next(1, 100);
            }
            SectionH.PrintArray(A2);

            //3---看s1里有没有s2
            Console.WriteLine("Please give us s1 and s2. We are going to check if s1 includes s2(regardless of capital letters).");
            Console.Write("Please enter s1:");
            string s1 = Console.ReadLine();

            Console.Write("Please enter s2:");
            string s2 = Console.ReadLine();

            SectionH.Instring(s1, s2);

            //4---显示s1中s2的开始位置
            SectionH.FindWord(s1, s2);

            //5---十六进制
            //使用第一题输入的num
            SectionH.hexadecimal(num);

            //6---c1代替c2
            Console.Write("Please enter a string:");
            string s = Console.ReadLine();

            Console.Write("Please enter the letter c1 which you want to be substituted:");
            string c1_ = Console.ReadLine();
            char   c1  = Convert.ToChar(c1_);

            Console.Write("Please enter the letter which is to substitute c1 in the string:");
            string c2_ = Console.ReadLine();
            char   c2  = Convert.ToChar(c2_);

            SectionH.Substitute(s, c1, c2);

            //7---将特定value值赋值给arr中的每个位置
            Random r7 = new Random();

            int[] array = new int[r7.Next(1, 10)];
            SectionH.SetArray(array, r7.Next(1, 10));
            SectionH.PrintArray(array);

            //8---变化原来array长度
            SectionH.ResizeArray(array, r7.Next(1, 10));

            //9---判断是否质数prime  并打印5-1000的质数
            int k;

            for (k = 5; k <= 1000; k++)
            {
                SectionH.IsPrime(k);
            }

            //10---矩阵相乘
            int[,] A = new int[r7.Next(1, 10), r7.Next(1, 10)];
            int[,] B = new int[r7.Next(1, 10), r7.Next(1, 10)];
            SectionH.MatrixMultiply(A, B);

            //11
        }