zoukankan      html  css  js  c++  java
  • 面向过程5----c#

    c#的语法看上去跟java好像

    c#是一门编程语言,主要用于.net框架开发中

    c#的文件名后缀是cs.   examp.cs

    hello word!


    using System;

    namespace HelloWold

    {

        class Hello

      {

        static void Main(string[] args) /*java中main函数是小写,string则是大写*/

        {

          /*我的第一个c#程序*/

          Console.WriteLine("hello world");

          Console.ReadKey();

        }

      } 

    }


     实现求二元一次方程的根


    root.cs

    using System;

    using 数学相关;

    namespace root

    {

      class Root

      {

        int a,b,c;/*假设已经赋值*/

        root=b*b-4*a*c;

        root1=(-b+Math.sqrt(root))/2/a;

        root2=(-b-Math.sqrt(root))/2/a;

               public string root(){

          if(a<0)

          {

               return Console.WriteLine("这不是二元一次方程");

          }

          else if(a=0)

          {

            return Console.WriteLine("有一个根,值是:"+root1);

          }

          else

          {

            return Console.WriteLine("有两个根,根一:"+root1+",  根二:"+root2);

          }

        }

      }

      class RootMain

      {

        static void Main(string[] args)

        {

          Root root=new Root();

                     root.root();

        }

      }

    }

  • 相关阅读:
    Scheduled定时任务的触发规则
    linux设置系统时间为当前网络时间
    idea控制台打印日志出现乱码
    Nginx配置高可用的集群
    Nginx实现负载均衡
    BigDecimal比较大小
    Java调用第三方系统接口获取数据
    sql中主要关键字的执行顺序
    ASP.NET.Core --Jenkins+Docker
    ASP.NET.Core --Swagger+Route
  • 原文地址:https://www.cnblogs.com/kaililikai/p/5804285.html
Copyright © 2011-2022 走看看