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();

        }

      }

    }

  • 相关阅读:
    记一下后续要看的点
    vue 封装request.js
    shuf命令简单用法
    Redis string 字符串
    Redis 事务操作
    Redis Zset 有序集合
    php操作redis的一些基本操作
    pytest自动化测试入门介绍
    idea&myeclipse 自动生成serialVersionUID
    leetCode1104. 二叉树寻路(medium)
  • 原文地址:https://www.cnblogs.com/kaililikai/p/5804285.html
Copyright © 2011-2022 走看看