• OUT函数及其熟练使用,split的用法


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace OUT函数
    {
        class Program
        {
            //public void outzhi(double a, double b, double c, out double j1, out double j2)
            public void outzhi(double a, double b, double c, out string  j1, out string  j2)
            {
                double de = b * b - 4 * a * c;
                if (de < 0)
                {
                    Console.WriteLine("函数没有实根");
                    j1 = j2 = "";
                    
                }
                else
                {
                    double x1 = (-b + Math.Sqrt(de)) / (2 * a);
                    double x2 = (-b - Math.Sqrt(de)) / (2 * a);
                    if (de == 0)
                    {
                        Console.WriteLine("方程有两个相同的实根");
                        j1 = j2 = x1.ToString();
                    }
                    else
                    {
                        Console.WriteLine("方程有两个不同的实根");
                        //Console.Write("x1=" + x1); Console.Write("  x2=" + x2);
                        j1 = x1.ToString();
                        j2 = x2.ToString();
                    }
                }
    
            }
    
    
            static void Main(string[] args)
            {
                Program hanshu = new Program();
                Console.Write("请输入a=");
                double a = double.Parse(Console.ReadLine());
                Console.Write("请输入b=");
                double b = double.Parse(Console.ReadLine());
                Console.Write("请输入c=");
                double c = double.Parse(Console.ReadLine());
                //double j1 = 0;
                //double j2 = 0;
                string j1 = "";
                string j2 = "";
                hanshu.outzhi(a, b, c, out j1, out j2);
                Console.WriteLine("第一个根x1=" + j1);
                Console.Write("第二个根x2=" + j2);
                Console.ReadLine();
    
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace _0630下午
    {
        class Program
        {
            public void  hou()
            {
                int sum = 0;
                for (int i = 10; i > 0; i--)
                {
                    if (i == 10)
                    {
                        sum = 1;
                    }
                    else
                    {
                        sum = (sum + 1) * 2;
                    }
                }
                Console.Write(sum);
            }
    
            public int jiafen(int  a)
            {
                a+= 10;
                return a;
            }
    
            public void jiafen2(int[] a)
            {
                int l= a.Length;
                for (int i = 0; i < l; i++)
                {
                    a[i] += 10;
                }
            }
    
            public int [] jiafen4(int[] a)
            {
                int l = a.Length;
                for (int i = 0; i < l; i++)
                {
                    a[i] += 10;
                }
                return a;
            }
    
            public void  jiafen3(int[] a, out int[] b)
            {
                int l = a.Length;
                for (int i = 0; i < l; i++)
                {
                    a  [i] = a[i] + 10;
                }
                b = a;
            }
    
            static void Main(string[] args)
            {
                //out 传值    形式参数:只给值,不给变量名(传值)    实际参数:将变量名传给函数(传址)
                //out是实参
    
                Program hanshu=new Program();
                //猴子
                //hanshu.hou();
                //Console.ReadLine();
    
                //输入班级人数,根据人数输入每个人的成绩
                //本班都是少数民族学生,每个人+10分
                //写一个专门+10分的函数,参数是这个分数的数组
                Console.WriteLine("请输入班级的人数");
                int renshu = int.Parse(Console.ReadLine());
                int[] fen = new int[renshu];
                for (int i = 0; i < renshu ;i++ )
                {
                    Console.WriteLine("请输入第{0}名同学的成绩",(i+1));
                    fen[i] = int.Parse(Console.ReadLine());
                }
                //for(int i=0;i <renshu ;i++)
                //{
                //    fen[i ]= hanshu.jiafen(fen[i]);
                //}
    
                //hanshu.jiafen2(fen );
                //hanshu.jiafen3(fen,out chengji);
    
                int []chengji=new int [renshu ];
                hanshu.jiafen3(fen,out chengji );
                foreach(int aa in chengji  )
                {
                    Console.WriteLine(aa );
                }
                foreach (int aa in fen )
                {
                    Console.WriteLine(aa);
                }
                Console.ReadLine();
    
    
    
            }
        }
    }

    split的使用

    愿我有生之年,得见您君临天下。 吾辈必当勤勉,持书仗剑耀中华。
  • 相关阅读:
    K2 BPM介绍(2)
    K2 BPM介绍(1)
    认识BPM
    使用VS Code发布博客
    IIS 使用 HTTP/2
    IIS 8的第一次请求不变慢如何配置
    C# 图片识别技术(支持21种语言,提取图片中的文字)
    第九讲 C#练习题
    c#基础 第八讲
    c#基础 第六讲
  • 原文地址:https://www.cnblogs.com/bloodPhoenix/p/5630508.html
Copyright © 2020-2023  润新知